I have a ListBox and wanting to set its ItemsSource to an ObservableCollection that I get from my cloud. I have to await this incoming collection and it is causing my itemssource not to be updated.
This is my approach. This is my xaml.cs constructor:
{
InitializeComponent();
GetEmployeeList();
}
And the method it calls:
private async void GetEmployeeList()
{
await EmployeeController.GetAllEmployees().ContinueWith(r =>
{
_employees = (r.Result);
EmployeeListBox.ItemsSource = _employees;
});
}
My EmployeeController.GetAllEmployees() returns an ObservableCollection. and _employees gets updated, however my EmployeeListBox doesn't show these objects. I have tried with a static hard coded collection and it works fine - so is it due to my async? Anyone got a suggestion?
- Thanks.