Issue
I have a list (List<Customer> l_Customer
) that gets data from an API. <Customer>
class includes fullname
that is of string value. How can i get only the full names from that list and display them on the Picker's dropdown list?
Solution
I make a simple example for your reference with MVVM.
Xaml:
<Picker ItemsSource="{Binding l_Customer}" ItemDisplayBinding="{Binding fullname}"></Picker>
Code behind:
public partial class Page14 : ContentPage
{
public Page14()
{
InitializeComponent();
this.BindingContext = new CustomerViewModel();
}
}
public class CustomerViewModel
{
public List<Customer> l_Customer { get; set; }
public CustomerViewModel()
{
l_Customer = new List<Customer>()
{
new Customer(){ fullname="A"},
new Customer(){ fullname="B"},
new Customer(){ fullname="C"},
};
}
}
public class Customer
{
public string fullname { get; set; }
}
Answered By - Wendy Zang - MSFT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.