Skip to Main Content
Programming WPF, 2nd Edition
book

Programming WPF, 2nd Edition

by Chris Sells, Ian Griffiths
August 2007
Intermediate to advanced content levelIntermediate to advanced
864 pages
25h 52m
English
O'Reilly Media, Inc.
Content preview from Programming WPF, 2nd Edition

Decorator

System.Object
    System.Windows.Threading.DispatcherObject
        System.Windows.DependencyObject
            System.Windows.Media.Visual
                System.Windows.UIElement
                    System.Windows.FrameworkElement
                        System.Windows.Controls.Decorator

Decorator 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.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming C#, 4th Edition

Programming C#, 4th Edition

Jesse Liberty
Programming C# 10

Programming C# 10

Ian Griffiths

Publisher Resources

ISBN: 9780596510374Supplemental ContentErrata Page