Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is App.xaml used for in Silverlight?

Tags:

silverlight

The default Silverlight project template creates a file called "App.xaml". What is this file used for?

like image 785
Craig Schwarze Avatar asked Jan 20 '10 02:01

Craig Schwarze


2 Answers

There are a couple different uses for this file. Essentially it is a derived class of Application.

  • Global Resource declarations - Using the Application.Resources property you can define application level resources. Such as styles, data templates and control templates.
  • Startup, Exit, and Error Handling Events (code-behind) - The code-behind of this file is used to handle application level events such as Startup, Exit and UnhandledException.
  • Application.Current Reference (code-behind) - This application is accessible via the global static variable Application.Current. You can cast this anywhere in your application.
  • Assigning RootVisual (code-behind) - The RootVisual is used to setup the startup Silverlight UserControl. This property needs to be set in the Startup event.
  • Install the application Out-Of-Browser (code-behind) - Using the Install method you can prompt the user to install the application Out-of-Browser.
  • Check for Application Updates (code-behind) - The CheckAndDownloadUpdateAsync method is used when the application is running out-of-browser to ensure that the .xap file is the latest.
like image 70
bendewey Avatar answered Sep 28 '22 08:09

bendewey


xaml stand for extensible application markup language. This is just an XML file that allows you to declare the UI for Silverlight and even .Net objects

app.xaml allows you to declare resources that are shared across the application. Also the app.xaml.cs contains the application level events:

  • Application_Startup
  • Application_Exit
  • Application_UnhandledException
like image 21
Waleed Al-Balooshi Avatar answered Sep 28 '22 08:09

Waleed Al-Balooshi