Application.MainWindow Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the out-of-browser application window.

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

Syntax

'Declaration
Public Property MainWindow As Window
public Window MainWindow { get; internal set; }

Property Value

Type: System.Windows.Window
The out-of-browser application window.

Exceptions

Exception Condition
UnauthorizedAccessException

The current thread is not the UI thread.

Remarks

The return value is not meaningful when the application is running within the browser.

You can use this property to programmatically manipulate an out-of-browser application window at run time. The properties of the returned Window instance are initialized from the corresponding WindowSettings properties in the application manifest.

You can set the properties of the Window class only in response to user-initiated actions unless the current application is an elevated trust application. For example, you can change the window size in a button Click event handler.

Version Information

Silverlight

Supported in: 5, 4

Platforms

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