Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Window.WindowState Property

Gets or sets a value that indicates whether the window is maximized, minimized, or in the normal state.

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

public WindowState WindowState { get; set; }

Property Value

Type: System.Windows.WindowState
A value that indicates the current state of the window. The default is Normal.

ExceptionCondition
NotSupportedException

The application is not running outside the browser.

UnauthorizedAccessException

The current thread is not the user interface (UI) thread.

SecurityException

When setting this property, except in response to a user-initiated action, the Application.Startup event has already occurred and Application.HasElevatedPermissions is false.

You use this property to provide an alternative to the window Minimize and Maximize buttons. This is particularly useful in trusted applications when you hide the window title bar and border. For information, see How to: Configure an Application for Out-of-Browser Support.

You can set this property only in the following cases:

The following code example demonstrates the use of this property.


// Maximize the main window.
private void MaxButton_Click(object sender, RoutedEventArgs e)
{
    if (Application.Current.IsRunningOutOfBrowser)
    {
        Application.Current.MainWindow.WindowState = WindowState.Maximized;
    }
}


Silverlight

Supported in: 5, 4

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

Community Additions

ADD
Show:
© 2015 Microsoft