I have a WPF application using the MVVM pattern that sometimes have to show a waitcursor when it is busy doing something the user has to wait for. Thanks to a combination of answers on this page: display Hourglass when application is busy, I have a solution that almost works (although it is not really MVVM in spirit). Whenever I do something time-consuming in my viewmodels I do this:
using (UiServices.ShowWaitCursor())
{
.. do time-consuming logic
this.SomeData = somedata;
}
(ShowWaitCursor() returns a IDisposable that shows the waitcursor until it is being disposed of) The last line in my example is where I set some property. This property is bound in my XAML, e.g. like this:
<ItemsControl ItemsSource="{Binding SomeData}" />
However, since this could be a long list of objects and sometimes with complex datatemplates, etc. the actual binding and rendering sometime takes a considerable amount of time. Since this binding takes places outside of my using statement the waitcursor will go away before the actual wait is over for the user.
So my question is how to do a waitcursor in a WPF MVVM application that takes databinding into account?