Is there a way to MarkBusy a BusinessListBase?

Is there a way to MarkBusy a BusinessListBase?

Old forum URL: forums.lhotka.net/forums/t/9466.aspx


c_manboy posted on Thursday, September 02, 2010

I'm using the BusyAnimation for WPF and have bound IsRunning to my BusinessListBase's IsBusy property as suggested.  It works wonderfully.

I have a public method on my BusinessListBase that recalculates all the child objects data which can take about 10 - 15 seconds.  I'd love to set the IsBusy property when this runs so that my BusyAnimation executes. 

I have tried executing a second BusyAnimation but it does not seem to be firing...at least it's not displaying.

Is there anyway to mark the list as busy?

RockfordLhotka replied on Thursday, September 02, 2010

.NET collections don't normally implement INotifyPropertyChanged, and the CSLA collection types don't either.

That means there's no notification mechanism by which data binding (hence BusyAnimation) would know that an IsBusy property has changed.

It is probably better to follow an MVVM design pattern, where the UI is bound to a viewmodel, which exposes the collection as a Model property (so you can bind to it as well). Then you can put an IsBusy property on the viewmodel, which is fine since your viewmodel can implement INotifyPropertyChanged.

This is all particularly easy if you use the ViewModel<T> base class in Csla.Xaml, since it provides support for most/all of this.

RockfordLhotka replied on Thursday, September 02, 2010

One other thng - this whole busy animation stuff will only work as expected if that long-running task is running on a background thread (using BackgroundWorker or something). Otherwise you'll block the UI thread and nothing will actually happen.

c_manboy replied on Thursday, September 02, 2010

I knew you were going to suggest MVVM.  I suspected the reasons you mentioned and I'm glad to have them confirmed. 

Thanks!

Copyright (c) Marimer LLC