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: 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. 
<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>