2
Answers

Adding Dropdown with Dynamic data [Picker] Also Getting data

MVVM And Xamarin  

My Code
XAML File

ViewModel File

List m_city = new List();
public List get_Cities { get; set; }
public void GetCity()
{
m_city = Database.DB.All().ToList();
var city_names = m_city.Select(x => new { x.Id , x.Name}).Distinct().ToList();
foreach (var item in city_names)
{
City get_City = new Models.City();
get_City.Id = item.Id;
get_City.Name = item.Name;
get_Cities.Add(get_City);
}
}

Answers (2)
0
arvind baldaniya
NA 282 13.3k 8y
Not Display Data 
My XAML File
 
<Picker x:Name="City" Title="City" HorizontalOptions="FillAndExpand" BindingContext="{Binding get_Cities}" SelectedIndex="{Binding CitySelectedIndex}" >
</Picker>
 
 
 
 
 
0
Madhanmohan Devarajan
NA 6.5k 471.5k 8y
Your code seems to be fine. Do you have any problem in populating the City dropdown dynamically?