ContentControl Content Model Overview
A ContentControl has a content property:
This topic contains the following sections.
- Using the Content Property
- Types that Share this Content Model
- Types that Can Contain ContentControl Objects
- Related Topics
Using the Content Property
A ContentControl's Content property is typically used to specify the information that appears inside a control when it is rendered. For example, a Button's content is the text, image or other element that appears inside the button when it is displayed.
The Content property supports both text and UIElement content.
Adding Text Content
The Content property accepts text. The following example shows how to add text content to a control.
Adding UIElement Content
The Content property can also accept a single UIElement as its content. The following example shows how to add a UIElement to a control.
Button btn2 = new Button(); Image myImage3 = new Image(); myImage3.Width = 16; myImage3.Height = 16; BitmapImage myBitmapImage3 = new BitmapImage(); myBitmapImage3.BeginInit(); myBitmapImage3.UriSource = new Uri(@"pack://application:,,,/images/fish.png"); myBitmapImage3.EndInit(); myImage3.Source = myBitmapImage3; btn2.Content = myImage3;
There are a wide variety of UIElement types that can be used as content, including those that belong to the following type families.
Types that Share this Content Model
See ContentControl Types for a list of types that use this content model.
Types that Can Contain ContentControl Objects
The ContentControl class can be used as content for the following types.
Note that this list only includes types distributed with Windows SDK.