1
votes

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

  1. Click menu item
  2. Set IsBusy = true
  3. No busy indicator shows up
  4. Change view (ChangeActiveItem(ViewModel, bool))
  5. View displays
  6. Busy indicator displays

How It Should Work

  1. Click menu item
  2. Set IsBusy = true
  3. Busy Indicator displays
  4. Change view
  5. View Displays and renders fully
  6. IsBusy = false
  7. 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

  1. Changing 'PublishOnUiThread' to 'PublishOnBackgroundThread'
  2. Ayyappan Subramanian suggestion
1
I think you should try worker.RunWorkerAsync(); IsBusy = true; - Ayyappan Subramanian
That didn't work unfortunately - Bacon

1 Answers

0
votes
  • change isBusy status in runworkercompleted
  • make isbusy public property
  • in page constructor add datacontext
  • IsBusy="{Binding IsBusy,UpdateSourceTrigger=PropertyChanged }"

    public void Handle(NavigationItemClicked message)
     {
     worker = new BackgroundWorker();
    
     worker.DoWork += (s, e) =>
      {
        ChangeActiveItem(QuestDetails, true);
    IsBusy = false;
    };
     worker.RunWorkerCompleted += (s, e) =>
     {
    
      IsBusy = true;
     };
    
     worker.RunWorkerAsync();
    }