UserControl.Content Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the content that is contained within a user control.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)


Public Property Content As UIElement
public UIElement Content { get; set; }
<UserControl ...>
<UserControl .../>

XAML Values

  • singleContentElement
    Exactly one object element for a class that derives from UIElement. This is almost always an object that can take child elements (such as a Panel) so that multiple elements can be added to content. XAML processing of a UserControl has a special behavior that sets this content to the otherwise protected Content property.

Property Value

Type: System.Windows.UIElement
The content of the user control.


Dependency property identifier field: ContentProperty

The XAML usage shown is special parsing handling of the otherwise protected Content property. When the partial classes of the UserControl subclass you define that serves as a page root are joined, the XAML content of the UserControl object element in page markup becomes the Content value of your page class, and the content of the loaded page in the application.


This following example creates a UserControl called NameReporter that asks for a name of a person, and reports it back to the user. The Content of NameReporter is a StackPanel. The TextBlock controls, TextBox controls, and Button are contained in the Children property of the StackPanel. For the complete example, see the UserControl class reference.

<UserControl x:Class="UserControlExample.NameReporter"
    xmlns:x="" >
  <StackPanel HorizontalAlignment="Center">

      <!--Create a Style for a TextBlock.-->
      <Style TargetType="TextBlock" x:Key="TextBlockStyle">
        <Setter Property="Foreground" Value="Navy"/>
        <Setter Property="FontSize" Value="14"/>
        <Setter Property="VerticalAlignment" Value="Bottom"/>

      <!--Create a Style for a TextBlock.-->
      <Style TargetType="TextBox" x:Key="TextBoxStyle">
        <Setter Property="Width" Value="200"/>
        <Setter Property="Height" Value="30"/>
        <Setter Property="Margin" Value="4"/>
        <Setter Property="FontSize" Value="14"/>
        <Setter Property="Background" Value="Blue"/>

    <TextBlock FontSize="18" Text="Enter your name."/>
    <StackPanel Orientation="Horizontal">
      <TextBlock Style="{StaticResource TextBlockStyle}">
                First Name:
      <TextBox Name="firstName" Style="{StaticResource TextBoxStyle}"/>
    <StackPanel Orientation="Horizontal">
      <TextBlock Style="{StaticResource TextBlockStyle}">
                Last Name:
      <TextBox Name="lastName" Style="{StaticResource TextBoxStyle}"  
    <Button Width="50" Content="Submit" Click="Button_Click"/>


Version Information


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0


For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.