WinUI’s Flexible Content Model
Data Templates define a user interface for data. It is often defined as a Resource.
contentcontrol
Consider ContentControl (the base class of Button, CheckBox, ListViewItem, others).
- ContentControldefines the- Contentproperty which is of type object.
- This is what allows you to assign an arbitrary object (and not just a string) to the Contentproperty.
ContentControl’s Content Property
- If a UIElement(base class ofPanelsandControls) is assigned toContentControl’sContentproperty, it is rendered.
- If any other object is assigned to ContentControl’sContentproperty, the result of itsToStringmethod is rendered.
datatemplate
Instead of relying on the ToString result, you can use a DataTemplate to define a UI for the object. In the DataTemplate:
- UI elements like panels and controls can be used.
- You can bind to the properties of the object that was assigned to the Contentproperty.
DataTemplate is an object that is assigned to ContentTemplate property of ContentControl:

itemscontrol
ContentControl is for a single object. ItemsControl is for a collection of objects.ItemsControl is the base class of ListView, ComboBox, others.
ItemsControl ItemsSource Property
ItemsControl has an ItemsSource property to which you can assign a collection of objects.
- The same rules as ContentControl.Contentapply toItemsControl.ItemsSource.
datatemplate
A DataTemplate can be assigned to ItemsControl’s ItemTemplate property:
