What is the purpose of APP. XAML? How to pass Parameters and use them?

Source: Internet
Author: User

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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.