Export (0) Print
Expand All

Application.InstallStateChanged Event

Silverlight

Occurs when the InstallState property value changes.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

public event EventHandler InstallStateChanged
<Application InstallStateChanged="eventhandler"/>

The following code example demonstrates how to use this event. This example is part of a larger example available in How to: Implement Offline Support for Out-of-Browser Applications.


Application app = Application.Current;
public MainPage()
{
    InitializeComponent();
    LayoutRoot.DataContext = Deployment.Current.OutOfBrowserSettings;
    UpdateUI();
    app.CheckAndDownloadUpdateCompleted += 
        App_CheckAndDownloadUpdateCompleted;
    app.InstallStateChanged += (s,e) => UpdateUI();
    NetworkChange.NetworkAddressChanged += 
        (s, e) => UpdateNetworkIndicator();

    MessageBox.Show(Deployment.Current.OutOfBrowserSettings
        .WindowSettings.WindowStyle.ToString());
}


...


private void UpdateUI()
{
    UpdateNetworkIndicator();

    installButton.Visibility =
        app.InstallState == InstallState.NotInstalled ?
        Visibility.Visible : Visibility.Collapsed;

    updateButton.Visibility =
        app.IsRunningOutOfBrowser ? 
        Visibility.Visible : Visibility.Collapsed;

    isRunningOutOfBrowserTextBlock.Text = 
        app.IsRunningOutOfBrowser.ToString();

    installStateTextBlock.Text = app.InstallState.ToString();
}

private void UpdateNetworkIndicator()
{
    networkIndicator.Visibility =
        app.IsRunningOutOfBrowser ?
        Visibility.Visible : Visibility.Collapsed;

    bool online = NetworkInterface.GetIsNetworkAvailable();

    networkIndicator.Text = online ?
        "ONLINE" : "OFFLINE";

    updateButton.Visibility = online ?
        Visibility.Visible : Visibility.Collapsed;
}


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft