
The Role of the Window Type
In addition to the Application type, most desktop WPF applications will make use of the Window type.
This represents the main window of your app, as well as any custom dialog boxes. As you can see, Window
gains a good deal of functionality from its inheritance chain.
You will come to know the role of many of these base classes during the remainder of this class. Here is a
high-level overview of the role of each class in the Window’s inheritance chain. The ContentControl parent
class allows derived types to host a single piece of ‘content’. WPF content can be composed of any sort of
UI elements. Most WPF controls also have ContentControl in their inheritance chain. Also, the Window
and Page types extend ContentControl.
The WPF content model allows you to radically change the composition of a control with minimal fuss. By
way of an example, a Button could maintain an inner StackPanel as ‘content’. The StackPanel contains an
Ellipse and Label. You will examine the content model in a later chapter. For now, here is a simple example
in XAML.
<!-- A Button containing a StackPanel as content. -->
<Button Height = "150" Width = "120">
<StackPanel>
<Ellipse Fill = "Orange" Height = "75" Width = "75"/>
<Label Content = "OK!" FontSize = "20"
HorizontalAlignment = "Center" />
</StackPanel>
</Button>
The Control parent class defines a number of members that give derived types (including Window) their core
look and feel. Properties exist to establish the control’s opacity, tab order logic, background color, font
settings, and so forth. The Control type also provides the infrastructure to apply templates and styles to a
UI widget.
FrameworkElement is another key parent class to many UI widgets in that it provides members to control
size, tooltips, mouse cursor, and other settings. This class also provides support for WPF animation and data
binding services.
UIElement provides the greatest amount of functionality:
• Events to process mouse and input focus.
• Properties to control focus, visibility, and geometric transformation.
Visual provides derived types the core infrastructure to render their UI output. Visual provides hit-testing
support and coordinates transformation. Visual is also the connection between WPF and the DirectX
subsystem. Any type extending Visual can be rendered on a Window.
DependencyObject is the parent that provides derived types the ability to work with the WPF ‘dependency
property’ model. As you will see later, a dependency property makes it possible for a property to receive
input from multiple locations. This is key part of WPF’s template, animation, and data binding services.
Finally, DispatcherObject provides access to the WPF app’s lower-level event queue via the Dispatcher
property. WPF makes use of a single-thread affinity model, hence the use of [STAThread] in your Main()
method.
The Role of the Window Type
Table of Contents
Copyright (c) 2008. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an
online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials
Services