Data templating is a feature of WPF and Xamarin.Forms that lets you customize the presentation of data.
Data templating is a feature of WPF and Xamarin.Forms that lets you customize the presentation of data. It is typically used by setting the ContentTemplate of a ContentControl.
Introduction on Microsoft Docs: Data Templating Overview
The example below use a DataTemplate
to define the data presentation in a ListBoxItem
, by a Panel with 3 TextBlocks
.
<ListBox Width="400" Margin="10"
ItemsSource="{Binding Source={StaticResource myTodoList}}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=TaskName}" />
<TextBlock Text="{Binding Path=Description}"/>
<TextBlock Text="{Binding Path=Priority}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>