O'Reilly logo

Microsoft Silverlight 4 Business Application Development Beginner's Guide by Frank LaVigne, Cameron Albert

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - checking the InstallState property

We are going to check to see if our application is already installed before installing it. If it is, we will alert the user by showing a messagebox. Otherwise, we will install it.

  1. Open the OutOfBrowserTestApp solution we just created in Visual Studio.
  2. Open up the MainPage.xaml.cs file and modify the btnInstallLocally_Click method, so that it contains the following code:
    private void btnInstallLocally_Click(object sender, RoutedEventArgs e)
    {
    if (Application.Current.InstallState == InstallState.Installed)
    {
    MessageBox.Show("Application already installed");
    }
    else
    {
    Application.Current.Install();
    }
    }
    
  3. Run the solution by pressing F5 or choosing Debug Solution from the Debug menu.
  4. Click on the Install ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required