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)

'Declaration
Public Property WindowState As WindowState

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 Sub MaxButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
    If Application.Current.IsRunningOutOfBrowser Then
        Application.Current.MainWindow.WindowState = WindowState.Maximized
    End If
End Sub


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:
© 2014 Microsoft