ContentControl
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Visual
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Control
System.Windows.Controls.ContentControlContentControl is a
specialization of Control. It's the
base class for any control that can host a single piece of content,
which goes in the Content property.
The content can be plain text or a tree of user interface elements
(e.g., a nested control, or a panel containing several child items). The
content can also be any .NET object, in which case WPF will attempt to
display it using a data template: if you set the ContentTemplate or ContentTemplateSelector property, WPF will use
the template you supply, but otherwise it will attempt to locate a
template automatically. If it can't find a template, it will display the
value returned by the object's ToString method. We describe data templates in
Chapter 6.
Some controls derive from ContentControl in order to offer a caption.
For example, the various button types (e.g., Button, CheckBox, RadioButton; see Chapter 5
for details) typically contain either text or graphics. By deriving from
ContentControl, these buttons are
able to host any mixture of text and graphics.
An alternative reason to derive from ContentControl is to offer a service wrapped
around arbitrary content. For example, ScrollViewer can host any content, providing scroll bars for when the content is larger than the ...