picker data can't bind inside the listview.

REJAHREJAH Member ✭✭
edited March 20 in Xamarin.Forms

              BindingContext = new RegistrationPageViewModel();

public class PickDataClass
{
public string Name { get; set; }
public string Address { get; set; }

  }

public class RegistrationPageViewModel : INotifyPropertyChanged
{

List<string> countries = new List<string>
{
    "Afghanistan",
    "Albania",
    "Algeria",
    "Andorra",
    "Angola"

};
        public List<string> Countries => countries;

        public event PropertyChangedEventHandler PropertyChanged;
  }

picker list can not populated inside the listview .if i taking picker outside the listview then data has come .plz help me in this regards .Thanks in Advance.

Answers

  • DoraBhujiDoraBhuji Member ✭✭✭

    @REJAH Please share code of picker where you bind this or something

  • DoraBhujiDoraBhuji Member ✭✭✭

    @REJAH
    Since you have static data in picker you can specfy it in Xaml itself

    Like this

    < Picker x:Name="countries " >
    < Picker.ItemsSource >
    < x:Array Type="{x:Type x:String}" >
    < x:String>Afghanistan
    < x:String>Albania
    < x:String>Algeria
    < x:String>Andorra
    < x:String>Angola
    </ x:Array >
    </ Picker.ItemsSource >
    </ Picker >

  • REJAHREJAH Member ✭✭

    I have dynamic data binding from database

  • REJAHREJAH Member ✭✭

    here xaml code inside the listview.

  • DoraBhujiDoraBhuji Member ✭✭✭

    for dynamic binding

    write this code

    protected async override void OnAppearing()
    {

            var pick = await _connection.Table<ExpenseCatMaster>().ToListAsync();
            expenseList.ItemsSource = pick;
             expenseList.ItemDisplayBinding = new Binding("ExCategory");
              base.OnAppearing();
                    }
    

    ExpenseCatMaster this is model from where u have to bind your picker with items
    ExCategory is item to be displayed

  • REJAHREJAH Member ✭✭

    @REJAH said:
    here xaml code inside the listview.

    @Sreedevi said:
    for dynamic binding

    write this code

    protected async override void OnAppearing()
    {

    var pick = await _connection.Table().ToListAsync();
    expenseList.ItemsSource = pick;
    expenseList.ItemDisplayBinding = new Binding("ExCategory");
    base.OnAppearing();
    }

    ExpenseCatMaster this is model from where u have to bind your picker with items
    ExCategory is item to be displayed

  • REJAHREJAH Member ✭✭

    in listview can't access x:name of picker to code behind.

  • DoraBhujiDoraBhuji Member ✭✭✭

    @REJAH i didn't get you

  • DoraBhujiDoraBhuji Member ✭✭✭

    @Sreedevi said:
    @REJAH Please share code of picker where you bind this or something

  • REJAHREJAH Member ✭✭

    this code inside the listview.

  • REJAHREJAH Member ✭✭

    this code inside the listview.

  • jezhjezh Member, Xamarin Team Xamurai

    Could you please post a basic demo so that we can test with it ?

Sign In or Register to comment.