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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfPicker: Customize Selected Item when using custom item view

Thread ID:

Created:

Updated:

Platform:

Replies:

149965 Dec 16,2019 12:58 PM UTC Dec 17,2019 11:04 AM UTC Xamarin.Forms 1
loading
Tags: SfPicker
Juan Ignacio Rodríguez
Asked On December 17, 2019 09:37 AM UTC

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.

Hemalatha Marikumar [Syncfusion]
Replied On 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. 


CONFIRMATION

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon