Export (0) Print
Expand All

Application.StartupUri Property

Gets or sets a UI that is automatically shown when an application starts.

Namespace:  System.Windows
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
<object StartupUri="Uri" .../>

Property Value

Type: System.Uri
A Uri that refers to the UI that automatically opens when an application starts.

ExceptionCondition
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

Window

Window

Standalone only

NavigationWindow

NavigationWindow

Standalone only

Page

NavigationWindow

Standalone/browser-hosted

UserControl

NavigationWindow

Standalone/browser-hosted

FlowDocument

NavigationWindow

Standalone/browser-hosted

PageFunction(Of T)

NavigationWindow

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.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft