0

i am binding an ItemsSource from a ObservableCollection with code below

Services.RestServices.GetNotifications(UserID, ++Page).ContinueWith((task) =>
        {
            Dispatcher.BeginInvoke((Action)(() =>
              {
                setNotListToBind(task.Result).ContinueWith(t =>
                  {
                      Dispatcher.BeginInvoke((Action)(() =>
                           {
                            var list = getFilteredNotList(notList, NotificationCategories.requests);
                            Dispatcher.BeginInvoke(() => NotificationContainer.ItemsSource = list;);
                           }));
                  });
              }));
        });

in above code i am using task-parallel-library to wait the excecution and within it i am binding the itemsSource with the dispature, but the UI not updating after binding.
here my itemsSource is NotificationContainer and the ObservableCollection is list

Ashok Damani
  • 3,896
  • 4
  • 30
  • 48

1 Answers1

0

If you know Services.RestServices.GetNotifications is being called from the UI thread, you could simplify the code by specifying the TaskScheduler instance on each call to ContinueWith using TaskScheduler.FromCurrentSyncronizationContext. Perhaps this can lead you closer to finding the issue.

Pedro Pombeiro
  • 1,654
  • 13
  • 14