Outofbrowser. XAML
<Button X: Name = "button" Click = "button_click" width = 100 Height = 30> </button>
Outofbrowser. XAML. CS
Public outofbrowser ()
{
Initializecomponent ();
This. Loaded + = new routedeventhandler (outofbrowser_loaded );
}
Void outofbrowser_loaded (Object sender, routedeventargs E)
{
Initbutton ();
App. Current. installstatechanged + = new eventhandler (current_installstatechanged );
}
Void current_installstatechanged (Object sender, eventargs E)
{
Initbutton ();
}
Private void button_click (Object sender, routedeventargs E)
{
If (! App. Current. isrunningoutofbrowser & App. Current. installstate = installstate. notinstalled)
App. Current. Install ();
Else
MessageBox. Show ("right-click to uninstall! ");
}
Private void initbutton ()
{
If (App. Current. isrunningoutofbrowser)
Button. content = "uninstall ";
Else
Button. content = "Install ";
}
Right-click Properties in solution, select Open, select Silverlight from the Open menu, and select allow applications to run outside the browser.ProgramClick the Settings button outside the browser. In the displayed window, set the title, height, and width of the window to be displayed after installation, as well as the shortcut name and download instructions. Save the settings, an outofbrowsersettings is generated in properties. XML file, which displays the information we Just configured.
Then run the command to install it!