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 put application-level resources here, usingApplication. ResourcesAttribute access, commonly used include styles, data templates, and control templates. Global Event Processing:Startup,ExitAndUnhandledexception. Global ReferenceApplication. Current Specify rootvisible:RootvisualThis property is used to set the Silverlight startup control.StartupSet in the event. Local InstallationApplication: UseInstallYou can install the application locally outside the browser. Check for updates: Can be used for local InstallationCheckanddownloadupdateasyncMethod to check whether the. xap file is up to date