I'm using WPF, Caliburn.Micro and WPF Extended Toolkit to display a busy indicator when I change the view that is displaying. The issue is that the busy indicator never displays between the views being switched (which is why I need it).
How It Works While Broken
- Click menu item
- Set IsBusy = true
- No busy indicator shows up
- Change view (ChangeActiveItem(ViewModel, bool))
- View displays
- Busy indicator displays
How It Should Work
- Click menu item
- Set IsBusy = true
- Busy Indicator displays
- Change view
- View Displays and renders fully
- IsBusy = false
- BusyIndicator hides
ShellView (BusyIndicator Snippet)
<xctk:BusyIndicator IsBusy="{Binding IsBusy}">
<ContentControl x:Name="ActiveItem" />
</xctk:BusyIndicator>
NavigationViewModel (Method - Fires when clicking a menu item)
public void NavigationItemClicked(NavigationItem item)
{
_eventAggregator.PublishOnUIThread(new NavigationItemClicked(item.ViewModelType));
}
ShellViewModel (Method - Catches message from NavigationViewModel.NavigationItemClicked)
public void Handle(NavigationItemClicked message)
{
worker = new BackgroundWorker();
worker.DoWork += (s, e) =>
{
ChangeActiveItem(QuestDetails, true);
IsBusy = false;
};
IsBusy = true;
worker.RunWorkerAsync();
}
Also Tried
- Changing 'PublishOnUiThread' to 'PublishOnBackgroundThread'
- Ayyappan Subramanian suggestion