Forum Xamarin.Forms

Picker selected item showing class name at zero position

A_VA_V USMember ✭✭✭
edited September 2019 in Xamarin.Forms

I am using picker in my xaml like
<Picker x:Name="pickerService" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" ItemDisplayBinding="{Binding ServiceName }"/>
My Service class is like

       public class Service
        {
          [PrimaryKey, AutoIncrement]
          public int Id { get; set; }
          public string ServiceName { get; set; }
        }

and adding list to picker itemssource like

     List<Service> serviceNames = new List<Service>();
     serviceNames = App.DAUtil.GetServices ();
     pickerService.ItemsSource = serviceNames ;

here I am getting serviceNames list from my local db.When I select a service from picker sometimes it is showing class name at zero position instead of "ServiceName", like "App.MainPage". Please help me to solve this.

Answers

Sign In or Register to comment.