I trying to fill a picker with json data from web api
<Picker x:Name="picker"
Title="Изберете станция"
TitleColor="Black">
</Picker>
In c# file:
public async Task FillStation_HQ_AHSAsync()
{
var result = await _restServiceStations.Get_HQ_AHS(Constants.EndPoint);
foreach (var item in result)
{
var stationsList = new List<string>();
stationsList.Add(item.ToString());
picker.ItemsSource = stationsList;
}
}
So result have more than 200 items with two properties: "Station" and "Ime".. but when I click on the picker he is empty..
CodePudding user response:
the logic for building your list is bad
var stationsList = new List<string>();
foreach (var item in result)
{
stationsList.Add(item.ToString());
}
picker.ItemsSource = stationsList;