WPF Concepts—A Tour of the Class Hierarchy
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| CSharp-Online.NET:Articles |
| .NET Articles |
| © 2007 Sams Publishing |
A Tour of the Class Hierarchy
WPF's classes have a very deep inheritance hierarchy, so it can be hard to get your head wrapped around the significance of various classes and their relationships. The inside cover of this book contains a map of these classes to help you put them in perspective as you encounter new ones. It is incomplete due to space constraints, but the major classes are covered.
A handful of classes are fundamental to the inner-workings of WPF, and deserve a quick explanation before we get any further in the book. Some of these have been mentioned in passing already. Figure 3.9 shows these important classes and their relationships without all the extra clutter from the inside cover.

Figure 3.9 The core classes in the WPF Presentation Framework.
These ten classes have the following significance:
-
Object—The base class for all .NET classes.
-
-
DispatcherObject—The base class for any object that wishes to be accessed only on the thread that created it. Most WPF classes derive fromDispatcherObject, and are therefore inherently thread-unsafe. TheDispatcherpart of the name refers to WPF's version of a Win32-like message loop.
-
-
DependencyObject—The base class for any object that can support dependency properties.DependencyObjectdefines theGetValueandSetValuemethods that are central to the operation of dependency properties.
-
-
Freezable—The base class for objects that can be "frozen" into a read-only state for performance reasons.Freezables, once frozen, can even be safely shared among multiple threads, unlike all otherDispatcherObjects. Frozen objects can never be unfrozen, but you can clone them to create unfrozen copies.
-
-
Visual—The base class for all objects that have their own visual representation.
-
-
UIElement—The base class for all visual objects with support for routed events, command binding, layout, and focus.
-
-
ContentElement—A base class similar toUIElement, but for pieces of content that don't have rendering behavior on their own. Instead,ContentElementsare hosted in aVisual-derived class to be rendered on the screen.
-
-
FrameworkElement—The base class that adds support for styles, data binding, resources, and a few common mechanisms for Windows-based controls such as tooltips and context menus.
-
-
FrameworkContentElement—The analog toFrameworkElementfor content.
-
-
Control—The base class for familiar controls such asButton,ListBox, andStatusBar.Controladds many properties to itsFrameworkElementbase class, such asForeground,Background, andFontSize.Controls also support templates that enable you to completely replace their visual tree. The next chapter examines WPF's Controls in depth.
-
Throughout the book, the simple term element is used to refer to an object that derives from UIElement or FrameworkElement, and sometimes ContentElement or FrameworkContentElement. The distinction between UIElement versus FrameworkElement or ContentElement versus FrameworkContentElement is not important because WPF doesn't ship any other public subclasses of UIElement and ContentElement.
|

