我的代码 我去创建动态数据(下拉列表)[Picker]但不显示数据
ViewModel.cs文件
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);
}
}
Xaml文件:
<Picker x:Name="City" BindingContext="{Binding get_Cities}">