Decorator
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Visual
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.DecoratorDecorator is the base class for
elements that contain a single child, and which either apply some kind
of effect or offer a service. For example, Border adds an outline and optional padding
around an element. ViewBox scales its
child to fit the space available. InkPresenter enables ink rendering on its
child.
Tip
Despite being defined in the System.Windows.Controls namespace, a
Decorator is not technically a
control, as it does not derive from the Control class. Indeed, many of the types in
the System.Windows.Controls
namespace are not controls. This namespace contains many utility types
typically used in conjunction with controls in order to build a user
interface.
Decorator is a very simple
class—it just defines a public Child
element and performs the necessary work to ensure that the child is
added to the logical and visual trees. Its layout implementation simply
defers to the child element. You should use either this or ContentControl when writing a custom element
that wraps a single child. See the ContentControl
section, later in this appendix, for a discussion on how to choose
between these two types.