I'm working in an application that takes its own content from a server. Each X seconds has to check if there have been changes and, if so, to refresh the related screens.
I'm trying to refresh the UI from the thread that checks if any changes have been uploaded, but the thing is that the code is executed but the view it's not refreshed.
Here's a sample of the code:
//Class that checks changes in server
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
() =>
{
//Page that has to refresh its UI
Home h = new Home();
h.RefreshData(update);
});
break;
//HOME Page
public void RefreshData(PushElement update)
{
_source.Clear(); //ObservableCollection<UserControl>, is the ItemsSource of the Main ListView of the Home page
NotifyPropertyChanged();
setContentFromProps("URL_HOME"); //Function that fills back the ListView
}
//Property bound to ItemsSource in the XAML
public ObservableCollection<UserControl> Source
{
get
{
return _source;
}
set
{
_source = value;
NotifyPropertyChanged();
}
}
If I put a breakpoint, the code is executed but the UI it's never refreshed. I have tried many ways to do it, but unsuccessfully... How could I achieve it?
Thanks in advance!