Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
145713 | Jul 4,2019 10:41 PM UTC | Jul 8,2019 01:43 PM UTC | Xamarin.Forms | 5 |
![]() |
Tags: SfComboBox |
XAML:
<ContentPage.Resources> <ResourceDictionary> <DataTemplate x:Key="default"> .. </DataTemplate>
<DataTemplate x:Key="specific"> .. </DataTemplate> </ResourceDictionary> </ContentPage.Resources> <ContentPage.Content> <StackLayout> <Label Text="High performance Mobiles" FontSize="Medium" FontAttributes="Bold"/> <Label Text="Choose a Device to place order" FontAttributes="None" FontSize="Micro"/> <combobox:SfComboBox DataSource="{Binding Data}" x:Name="comboBox" DisplayMemberPath="dsproduct"> <combobox:SfComboBox.ItemTemplate> <local:MyDataTemplateSelector DefaultTemplate="{StaticResource default}" SpecificDataTemplate="{StaticResource specific}"/> </combobox:SfComboBox.ItemTemplate> </combobox:SfComboBox> </StackLayout> </ContentPage.Content> </ContentPage> C#
protected override DataTemplate OnSelectTemplate(object item, BindableObject container) { var message = item as Product; return message.amount <= 0 ? DefaultTemplate : SpecificDataTemplate; } |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.