Yes, I'm a noob and I have probably a silly question...
I'm populating a listview with my viewmodel and it works fine if I statically assign values, but when I try to run an async task which loops through a list to add the values it does not populate my listview.
Here's the code behind I'm using:
`
public class ViewModel
{
public ViewModel()
{
Task.Run(async () => { await GetCatsAsync(); });
}
public List<SourceItem> Source { get; set; }
public async Task GetCatsAsync()
{
List<groceryList> itemsT = new List<groceryList>(await App.GroceryRepo.GetAllCategoriesAsync());
foreach (var groceryList in itemsT)
{
if (groceryList.CategoryHead)
{
this.Source.Add(new SourceItem(groceryList.Category.ToString()));
}
}
}
}
public class SourceItem
{
public SourceItem(string name)
{
this.Name = name;
}
public string Name { get; set; }
}`
And here's my xaml:
`
<ContentPage.BindingContext>
viewModels:ViewModel x:Name="ViewModel"
</ContentPage.BindingContext>
<telerikDataControls:RadListView x:Name="listViewModelTest" ItemsSource="{Binding Source}" HeightRequest="200">
<telerikDataControls:RadListView.ItemTemplate>
<DataTemplate>
<listView:ListViewTemplateCell>
<listView:ListViewTemplateCell.View>
<Grid>
<Label Margin="10" Text="{Binding Name}" />
</Grid>
</listView:ListViewTemplateCell.View>
</listView:ListViewTemplateCell>
</DataTemplate>
</telerikDataControls:RadListView.ItemTemplate>
</telerikDataControls:RadListView>`
The list itemsT does retrieve data and it hits my foreach but does not populate my listview.
Any ideas?