ItemsControl - markjulmar/xamu-infrastructure GitHub Wiki
ItemsControl
The ItemsControl control is a simple, bindable template creator which will instantiate a set of Label elements or DataTemplate driven elements from a bound list. Similar to a ListView, but the produced content is not scrollable, nor does it provide any interactivity outside the generate content.
Properties
PlaceholderText: astringwhich is displayed when there is no data to render.ItemsSource: the collection of data to render. This can be anyIEnumerabletype.ItemStyle: theStyleapplied to any generatedLabelelements, including the placeholder text. If not supplied, the defaultStyleforLabelis used. This can be used to customize the generated labels.ItemTemplate: theDataTemplateorDataTemplateSelectorused to create the visualization for each item in theItemsSourcecollection. If not supplied, simpleLabelelements are generated andToStringis executed on each object to provide the text.
Example
<Page xmlns:xamucontrols="clr-namespace:XamarinUniversity.Controls;assembly=XamU.Infrastructure" ..>
...
<xamucontrols:ItemsControl
ItemsSource="{Binding Entries}"
ItemStyle="{DynamicResource LabelEntryStyle}"
PlaceholderText="{Binding Title, StringFormat='No {0} Entered'}">
<!-- System inflates one of these for every item in Entries collection -->
<xamucontrols:ItemsControl.ItemTemplate>
<DataTemplate>
<StackLayout>
<Label Text="{Binding Details}" />
<!-- Other data bound elements here -->
...
</StackLayout>
</DataTemplate>
</xamucontrols:ItemsControl.ItemTemplate>
</xamucontrols:ItemsControl>