Gets or sets the content of a ContentControl.
Assembly: PresentationFramework (in PresentationFramework.dll)
Because the Object, there are no restrictions on what you can put in a ContentControl. The is displayed by a ContentPresenter, which is in the ControlTemplate of the ContentControl. Every ContentControl type in WPF has a ContentPresenter in its default ControlTemplate. For more information about how the ContentPresenter displays , see ContentPresenter.property is of type
Text or a single object.
The following example demonstrates how to create four Button controls with set to one of the following:
A DateTime object.
A UIElement object.
Although the Extensible Application Markup Language (XAML) version of the example could use the <Button.Content> tags around the content of each button, it is not necessary. For more information, see XAML Overview (WPF).
<!--Create a Button with a string as its content.--> <Button>This is string content of a Button</Button> <!--Create a Button with a DateTime object as its content.--> <Button xmlns:sys="clr-namespace:System;assembly=mscorlib"> <sys:DateTime>2004/3/4 13:6:55</sys:DateTime> </Button> <!--Create a Button with a single UIElement as its content.--> <Button> <Rectangle Height="40" Width="40" Fill="Blue"/> </Button> <!--Create a Button with a panel that contains multiple objects as its content.--> <Button> <StackPanel> <Ellipse Height="40" Width="40" Fill="Blue"/> <TextBlock TextAlignment="Center">Button</TextBlock> </StackPanel> </Button>
The following illustration shows the four buttons created in the previous example.
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0