Export (0) Print
Expand All

Window.Hide Method

Updated: July 2008

Makes a window invisible.

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

public void Hide()
You cannot use methods in XAML.

ExceptionCondition
InvalidOperationException

Hide is called on a window that is closing (Closing) or has been closed (Closed).

A window is not closed when it is hidden, and neither the Closing nor Closed event is raised. Instead, the window's Visibility property is set to Visibility.Hidden.

If a window is the application's MainWindow and the application's ShutdownMode is OnMainWindowClose, the application does not shut down. Likewise, the application does not shut down if a window is the only window and the application's shutdown mode is OnLastWindowClose.

If you want to show and hide a window multiple times during the lifetime of an application, and you don't want to re-instantiate the window each time you show it, you can handle the Closing event, cancel it, and call the Hide method. Then, you can call Show on the same instance to re-open it. See Hide a Window Without Closing Sample.

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

Date

History

Reason

July 2008

Added description of how to hide a window without closing it.

Information enhancement.

Community Additions

ADD
Show:
© 2014 Microsoft