#39 – The Window Class

The Window class represents a window in WPF.  It derives from ContentControl, which means that it can contain a single nested element that represents its content.  It inherits directly from Control and indirectly from FrameworkElement, UIElement, Visual, DependencyObject, and DispatcherObject.

A window consists visually of a client area (the inside of the window) and non-client area (title bar, frame and minimize/maximize/close buttons).  It represents the main (outer) visual element that a user interacts with for a WPF standalone application.

You can manage a window’s lifetime through methods like Activate, Close, Hide and Show and events like Activated, Closed, Closing, and Deactivated.

The following XAML:

<Window x:Class="WpfApplication9.MainWindow"
 Title="MainWindow" Height="200" Width="250">
        <Label Content="I'm a WPF Window!" Height="28" HorizontalAlignment="Center" VerticalAlignment="Center" />

Results in this window at runtime:


Get every new post delivered to your Inbox.

Join 446 other followers