In Silverlight, there is an app. XAML and App. XAML. cs. What is it, what is its purpose, and how to pass parameters with it?
Using the public parameter in it is very simple. Suppose you can access it in mainpage. XAML. CS as follows:
(Application. CurrentAsAPP). yourpublicparam
Similarly, in the Silverlight Class Library Project, you can use the above method to access the variables in the app, because application. Current is global for the application.
App. XAML Source
App. XAML and App. XAML. CS exist in Silverlight and WPF projects.System. Windows. ApplicationClass Library. If you are familiar with winform development, you should be familiar with this. When the Silverlight application is started, the order is as follows:
No main () method StartAppConstructor
- SetApplication_startupEvent Handler boundApp. startupAttribute
- SetApplication_exitEvent Handler boundApp. ExitAttribute
- SetApplication_unhandledexceptionEvent Handler boundUnhandledexceptionAttribute
- TriggerInitializecomponent
Application_startup
- Create a newPage object instance
- SetApp. rootvisual points to this page object
Initializecomponent
- CallApplication. loadcomponent, TransferUriObjectApp. XAML
App. XAML usage
Define Global Resources: We can place application-level resources here and access them using the application. Resources attribute. Commonly used resources include styles, data templates, and control templates. Global Event Processing: Startup, exit, and unhandledexception. Global ReferenceApplication. Current Specify rootvisible: Rootvisual is used to set the Silverlight startup control. This attribute is set in the startup event. Local InstallationApplication: You can use the install method to allow users to install the application locally outside the browser. Check for updates: During local installation, you can use the checkanddownloadupdateasync method to check whether the. xap file is up to date.