This repository was archived by the owner on Aug 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
ItemsControl
Mark Smith edited this page Apr 10, 2018
·
4 revisions
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.
-
PlaceholderText
: astring
which is displayed when there is no data to render. -
ItemsSource
: the collection of data to render. This can be anyIEnumerable
type. -
ItemStyle
: theStyle
applied to any generatedLabel
elements, including the placeholder text. If not supplied, the defaultStyle
forLabel
is used. This can be used to customize the generated labels. -
ItemTemplate
: theDataTemplate
orDataTemplateSelector
used to create the visualization for each item in theItemsSource
collection. If not supplied, simpleLabel
elements are generated andToString
is executed on each object to provide the text.
<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>