August 20, 2010 Leave a comment
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" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="200" Width="250"> <Grid> <Label Content="I'm a WPF Window!" Height="28" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Grid> </Window>
Results in this window at runtime: