We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SfPicker: Customize Selected Item when using custom item view

Is there any way to customize selected item when using custom view (or ItemTemplate)?

ItemTemtemplate and CustomViews are great but right now you loose the feature to have diferente color or aspect for the selected item. This is a big deal specially in android because selected item is indistinguishable from unselected ones.

Thansk.

1 Reply

HM Hemalatha Marikumar Syncfusion Team December 17, 2019 11:04 AM UTC

Hi Juan Ignacio Rodríguez, 
  
Greetings from Syncfusion. 
  
We have validated your query and prepared a workaround sample based on your requirement to differentiate SelectedItemTextColor & UnSelectedItemTextColor when using with Custom view (Item Template). Please find the code snippet and sample 
  
Code Snippet [XAML]
<picker:SfPicker  x:Name="picker" 
                          ItemsSource="{Binding Colors}" 
                          HeaderText="Select a Color" 
                          UnSelectedItemTextColor="Gray" 
                          SelectedItemTextColor="Red" 
                          SelectionChanged="Picker_SelectionChanged" > 
                <picker:SfPicker.ItemTemplate> 
                    <DataTemplate> 
                        <StackLayout> 
                            <Label Text="{Binding Name}" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" TextColor="{Binding ColorValue}"/> 
                        </StackLayout> 
                    </DataTemplate> 
                </picker:SfPicker.ItemTemplate> 
            </picker:SfPicker>  
 
  
Code Snippet [C#]: 
 private void Picker_SelectionChanged(object sender, Syncfusion.SfPicker.XForms.SelectionChangedEventArgs e) 
        { 
            var picker = (sender as SfPicker); 
  
            if (e.NewValue != null) 
            { 
                (e.NewValue as PickerColor).ColorValue = picker.SelectedItemTextColor; 
            } 
            if (e.OldValue != null) 
            { 
                (e.OldValue as PickerColor).ColorValue = picker.UnSelectedItemTextColor; 
            } 
        } 
 
 
  
Please let us know, if you have any other concern. 
 
Regards, 
Hemalatha M. 


Loader.
Live Chat Icon For mobile
Up arrow icon