Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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
public Uri StartupUri { get; set; }
<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<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.

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.

.NET Framework

Supported in: 3.5, 3.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.