Understanding the .NET 3.0 Windows Presentation Foundation
(WPF) Architecture This
article covers the .NET 3.0's Windows Presentation Foundation (WPF) architecture.
It provides information about the major subsystems of WPF and how they interact
with them.
The major subsystems of the Windows Presentation Foundation are: · Object · Threading.DispatcherObject · Windows.DependancyObject · Windows.Media.Visuals · Windows.UIElements · Windows.FrameworkElement · Windows.Controls.Control Architecture: The details of subsystem are given below: Object In WPF Milicore subsystem is designed as unmanaged code, because it has to access the memory of DirectX unmanaged code. Even though CLR provided lot of advantages like memory management, and common exception handling, the performance was considered as main requirement. This approach also allows the Milicore to have fine control over the hardware and software rendering. The Milicore and managed portion of the presentation subsystem interact with each other using windows messaging. Threading.DispatcherObject The Dispatcher system is for handling messages from other object. This dispatcher contains multiple prioritized queues. The DispatcherObject is designed as STA threading model, in which single thread is accessing the object methods and properties. The main reason for this is interoperability with other USER32 components like OLE32 and Clibboard. The most of the objects in WPF are derived from DispatcherObject, so that each object will have a message queue. The windows messages are also handled using this message queue. These messages includes device input like mouse and keyboard events, framework messages which are part of layout control phase, and commands like menu command etc. Windows.DependencyObject The DependencyObject is the system to define the properties of objects. The properties of one object bind to other object property using binding object. The WPF classws are defined with dozens of properties. The methods and events are used less. There is a concept property expression, which is the base for property system. In this version this interface is not allowed used outside the framework. There are other concepts in DependancyObject, like property values with sparse storage, attached properties and events, which are similar to javascript's "expando" feature. Windows.Media.Visual Once
the system is in place next thing to do is drawing pixels. There are fundamental
differences in drawing pictures in user32 and WPF. In user32, windows clip the
portion of the component currently getting drawn, so that component can change
the pixels with the window rectangle. No pixel on the screen is drawn twice. In
WPF every components draw from back to front. This design makes the drawing of
transparent windows possible. Example Windows.UIElement Components get positioned based on the layout property. There are two phases like Measure and Arrange in layout. The panel asks the child to controls to measure themselves before doing layout. Events like mouse events are handled by UIElements in two phases, tunnel and bubble. These events traverse through the elements tree in the application UI and any element can handle these events, even like keyboard accelerator events can be handled by any window. Windows.FrameworkElement Windows.Controls.Control The controls separates the data model and interaction model and display model. The separation of data model - properties, interaction model - commands and events, and display model - templates make the customization of a control's look and behavior easier. The
content property of the controls is forming the data model. The WPF controls can
contain data of any type, like strings and complex type like person. To display
complex types in control data templates can be used.
|