'Declaration
Public Property ItemTemplate As DataTemplate
'Usage
Dim instance As ComboBox Dim value As DataTemplate instance.ItemTemplate = value value = instance.ItemTemplate
public DataTemplate ItemTemplate {get; set;}
'Declaration
Public Property ItemTemplate As DataTemplate
'Usage
Dim instance As ComboBox Dim value As DataTemplate instance.ItemTemplate = value value = instance.ItemTemplate
public DataTemplate ItemTemplate {get; set;}
In the following example, the ItemsSource uses a binding on the UserObjects property of the ContentPage, which is a collection of objects representing various persons.
Each object, meaning each person in the collection, is represented in the ComboBox as a horizontal stack layout containing two horizontal labels; the second label is using a binding on the Name property, which is found within each object & represents the name of the person associated with said object, in order to get the names of the persons in the collection.
<xctk:ComboBox WidthRequest="200" ItemsSource="{Binding UserObjects, Source={x:Reference _contentPage}}"> <xctk:ComboBox.ItemTemplate> <DataTemplate> <HorizontalStackLayout Margin="5" Background="Yellow"> <Label Text="This is" Margin="5"/> <Label Text="{Binding Name}" Margin="5"/> </HorizontalStackLayout> </DataTemplate> </xctk:ComboBox.ItemTemplate> </xctk:ComboBox>
Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2