But when i populate the same list with async method i can't see the list view get populate. I used the breakpoints to check whether the methods are working or not. But the methods are all working fine. even my observable collection get populated. but i can't able see the list view.
My async program:
Margin="10,0,0,0" Foreground="Red"/>
Foreground="Red" Name="MyProgress"/>
ItemTemplate="{StaticResource ListViewTemplate}">
My class:
public class ListItem
{
public float Number { get; set; }
}
public class ListManager
{
public async static Task
- > GetItemsAsync()
{
var listItems = new List
Rootobject temperatures = await getTemperatureAsync();
for (int i = 0; i < 3; i++)
{
listItems.Add(new ListItem() { Number = temperatures.hourly.data[i].temperature });
}
return listItems;
}
private async static Task
{
HttpClient client = new HttpClient();
var jsonData = await client.GetStringAsync("https://api.darksky.net/forecast/apikey /13.08,80.27?units=si");
var parsedData = JsonConvert.DeserializeObject
return parsedData;
}
}
Mainpage.xaml.cs
ObservableCollection
public MainPage()
{
this.InitializeComponent();
ThisMethod().GetAwaiter();
}
private async Task ThisMethod()
{
MyProgress.Visibility = Visibility.Visible;
ObservableCollection
ListItems = items;
MyProgress.Visibility = Visibility.Collapsed;
}
Replies
Know the answer? Post it — somebody with the same question will find it here.