Export (0) Print
Expand All

Application.Startup Event

Occurs when an application is started.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

public event StartupEventHandler Startup
<Application Startup="eventhandler"/>

A typical Silverlight application may perform a variety of initialization tasks when it starts up, including:

  • Processing initialization retrieved from the InitParams property of the StartupEventArgs object that is passed to the Startup event handler.

  • Showing the application's main application UI by setting the RootVisual property.

  • Initialize application-scoped properties by setting custom properties implemented by the application class.

Additionally, Startup is an appropriate location for performing other common initialization tasks, loading data from the previous application session, and logging.

The following code shows how to handle the Startup event.


using System.Windows; // Application, StartupEventArgs

namespace SilverlightApplication
{
    public partial class App : Application
    {
        public App()
        {
            this.Startup += this.Application_Startup;
            InitializeComponent();
        }

        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Detect when the application starts up.
        }
    }
}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft