Académique Documents
Professionnel Documents
Culture Documents
12/19/13
The most practical way to create a custom class that extends WPF is by deriving from one of the WPF classes where you get as much as possible of your desired functionality through the existing class hierarchy. This section lists the functionality that comes with three of the most important element classes to help you decide which class to inherit from. If you are implementing a control, which is really one of the more common reasons for deriving from a WPF class, you probably want to derive from a class that is a practical control, a control family base class, or at least from the Control base class. For some guidance and practical examples, see Control Authoring Overview. If you are not creating a control and need to derive from a class that is higher in the hierarchy, the following sections are intended as a guide for what characteristics are defined in each base element class. If you create a class that derives from DependencyObject, you inherit the following functionality: GetValue and SetValue support, and general property system support. Ability to use dependency properties and attached properties that are implemented as dependency properties. If you create a class that derives from UIElement, you inherit the following functionality in addition to that provided by DependencyObject: Basic support for animated property values. For more information, see Animation Overview. Basic input event support, and commanding support. For more information, see Input Overview and Commanding Overview. Virtual methods that can be overridden to provide information to a layout system. If you create a class that derives from FrameworkElement, you inherit the following functionality in addition to that provided by UIElement: Support for styling and storyboards. For more information, see Style and Storyboards Overview. Support for data binding. For more information, see Data Binding Overview. Support for dynamic resource references. For more information, see XAML Resources. Property value inheritance support, and other flags in the metadata that help report conditions about properties to framework services such as data binding, styles, or the framework implementation of layout. For more information, see Framework Property Metadata. The concept of the logical tree. For more information, see Trees in WPF. Support for the practical WPF framework-level implementation of the layout system, including an OnPropertyChanged override that can detect changes to properties that influence layout. If you create a class that derives from ContentElement, you inherit the following functionality in addition to that provided by DependencyObject: Support for animations. For more information, see Animation Overview. Basic input event support, and commanding support. For more information, see Input Overview and Commanding Overview. If you create a class that derives from FrameworkContentElement, you get the following functionality in addition to that
msdn.microsoft.com/en-us/library/ms743618(d=printer,v=vs.110).aspx 2/4
12/19/13
provided by ContentElement: Support for styling and storyboards. For more information, see Style and Animation Overview. Support for data binding. For more information, see Data Binding Overview. Support for dynamic resource references. For more information, see XAML Resources. Property value inheritance support, and other flags in the metadata that help report conditions about properties to framework services like data binding, styles, or the framework implementation of layout. For more information, see Framework Property Metadata. You do not inherit access to layout system modifications (such as ArrangeOverride). Layout system implementations are only available on FrameworkElement. However, you inherit an OnPropertyChanged override that can detect changes to properties that influence layout and report these to any content hosts. Content models are documented for a variety of classes. The content model for a class is one possible factor you should consider if you want to find an appropriate class to derive from. For more information, see WPF Content Model.
Visual
Visual implements the concept of a 2D object that generally requires visual presentation in a roughly rectangular region. The actual rendering of a Visual happens in other classes (it is not self-contained), but the Visual class provides a known type that is used by rendering processes at various levels. Visual implements hit testing, but it does not expose events that report hit-testing positives (these are in UIElement). For more information, see Visual Layer Programming.
Freezable
Freezable simulates immutability in a mutable object by providing the means to generate copies of the object when an immutable object is required or desired for performance reasons. The Freezable type provides a common basis for certain graphics elements such as geometries and brushes, as well as animations. Notably, a Freezable is not a Visual; it can hold properties that become subproperties when the Freezable is applied to fill a property value of another object, and those subproperties might affect rendering. For more information, see Freezable Objects Overview. Animatable Animatable is a Freezable derived class that specifically adds the animation control layer and some utility members so that currently animated properties can be distinguished from nonanimated properties.
msdn.microsoft.com/en-us/library/ms743618(d=printer,v=vs.110).aspx 3/4
12/19/13
Control
Control is the intended base class for the type of object that is variously termed a control or component, depending on the technology. In general, WPF control classes are classes that either directly represent a UI control or participate closely in control composition. The primary functionality that Control enables is control templating.
See Also
Reference
Control
Concepts
Dependency Properties Overview Control Authoring Overview WPF Architecture
msdn.microsoft.com/en-us/library/ms743618(d=printer,v=vs.110).aspx
4/4