User Tools

Site Tools


notes:uwp:datatemplate

This is an old revision of the document!


DataTemplate in XAML

DataTemplate is usually used with list controls such as ItemsControl, GridView, or ListView.

Examples of a DataTemplates defined inline by setting the ItemTemplate property. The ItemTemplate property is of type DataTemplate:

<ItemsControl>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Rectangle Width="100" Height="50" Margin="10">
                <Rectangle.Fill>
                    <SolidColorBrush Color="{Binding}" />
                </Rectangle.Fill>
            </Rectangle>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
 
    <Color>Blue</Color>
    <Color>Red</Color>
    <Color>Green</Color>
    <Color>Magenta</Color>
</ItemsControl>
notes/uwp/datatemplate.1482327454.txt.gz · Last modified: 2020/08/26 (external edit)