ContentControl Class
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)] [ContentPropertyAttribute("Content")] public class ContentControl : Control, IAddChild
/** @attribute LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) */
/** @attribute ContentPropertyAttribute("Content") */
public class ContentControl extends Control implements IAddChild
LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) ContentPropertyAttribute("Content") public class ContentControl extends Control implements IAddChild
<ContentControl> Content </ContentControl>
A ContentControl has a limited default style. If you want to enhance the appearance of the control, you can create a new control template. For more information, see Data Templating Overview. Another typical scenario is to use the ContentControl to show more information about an item selected in an ItemsControl control. For more information, see How to: Bind to a Collection and Display Information Based on Selection.
Content Model: ContentControl is the class from which other content controls inherit. For more information on the content model for ContentControl, see ContentControl Content Model.
The following example shows how to make a style for a ContentControl so that the control has an enhanced visual appearance.
<Style x:Key="ContentCtrl" TargetType="{x:Type ContentControl}"> <Setter Property="Background" Value="Red"/> <Setter Property="Foreground" Value="Green"/> <Setter Property="FontSize" Value="20"/> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ContentControl}"> <Grid> <!--Keep the Ellipse a circle when ContentControl.Width is set.--> <Ellipse Width="{TemplateBinding Width}" Height="{TemplateBinding Width}" Fill="{TemplateBinding Background}"/> <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.