Application.StartupUri Property
Gets or sets a UI that is automatically shown when an application starts.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
'Declaration Public Property StartupUri As Uri 'Usage Dim instance As Application Dim value As Uri value = instance.StartupUri instance.StartupUri = value
<object StartupUri="Uri" .../>
Property Value
Type: System.UriA Uri that refers to the UI that automatically opens when an application starts.
| Exception | Condition |
|---|---|
| ArgumentNullException | StartupUri is set with a value of null. |
You can use StartupUri to automatically load a UI resource when an application starts.
The following table shows the types of UI resources that can be loaded, the type of window they are opened into, and the type of application that these resources can be set as the StartupUri.
Type | Window | Application type |
|---|---|---|
Standalone only | ||
Standalone only | ||
Standalone/browser-hosted | ||
Standalone/browser-hosted | ||
Standalone/browser-hosted | ||
Standalone/browser-hosted |
Typically, you set the StartupUri property declaratively in XAML. However, you can set StartupUri programmatically, such as from a Startup event handler, which is useful if for applications that can only load the necessary UI resources at run time. For example, an application might wait until run time to load its resources if the name of the UI resource is stored in a configuration file.
Whether you set StartupUri declaratively or programmatically, the corresponding UI resource is not loaded until after the Startup event is handled. Consequently, you won't have access to the resulting window from either the Windows property or the MainWindow property when handling Startup.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.