Gets or sets the main window of the application.
Assembly: PresentationFramework (in PresentationFramework.dll)
is set from an application that's hosted in a browser, such as an XAML browser applications (XBAPs).
You can specify a different main window by setting Windows object to the property.assigning another
It is possible to set the StartupUri property in XAML. The two limitations of the XAML approach are:property from XAML, if an application's main window is not the window that is produced by setting the
You must set the Visibility property of the window you specify, otherwise it won't be shown.
The reference to the first Window object to be instantiated is also added as the first item to the Windows collection. If is subsequently set with a reference to a different Window, the position of the item with the reference to the main window will change, while the order of items in Windows remains the same. Consequently, always use to refer to the main window instead of the first item in Windows.
The following example shows how to find the main application window.
The following example shows how to setusing XAML.
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="StartupWindow.xaml" > <Application.MainWindow> <NavigationWindow Source="MainPage.xaml" Visibility="Visible"></NavigationWindow> </Application.MainWindow> </Application>
The following example shows how to instantiate thein code during application startup.
Available since 3.0
Available since 4.0