Tracking Active View changes on TabControl Region

Jul 5, 2008 at 10:09 AM
Hello:

I have an application with a common toolbar for all the application views ( with buttons of new, edit, delete, save, ... ), that will be displayed in a TabControl region, the commands fired by the toolbar buttons should be executed only on the current Active view, i'm using the Model-View-ViewModel pattern to impement the views, the ViewModel implementation registers/unregisters the commands used by the toolbar buttons, what i want to do is to being able to track active view changes in the ViewModel to activate/deactivate the commands depending on wheter the View is active in the TabControl region or not, what will be the best way to achieve this ??

Excuse my bad english :)

Thanks in advance.
Jul 6, 2008 at 2:00 AM

I think i have found one way to do this by implementing the IActiveAware interface in the views, will this be the best way ??


Thanks in advance.
Developer
Jul 8, 2008 at 5:34 PM

There are a couple ways to handle this. 

One way, as you point out, is to use the IActiveAware interface and the RegionAdapter will notify all items in the collection when they become active.

An alternative approach is to monitor the Region's ActiveViews property.  ActiveViews implements INotifyCollectionChanged so you can determine if the current view is in the ActiveViews or not. 

HTH,

-b

Jul 11, 2008 at 5:24 PM
Hello:

Sorry for the delay :)


brumfb wrote:

There are a couple ways to handle this. 

One way, as you point out, is to use the IActiveAware interface and the RegionAdapter will notify all items in the collection when they become active.

An alternative approach is to monitor the Region's ActiveViews property.  ActiveViews implements INotifyCollectionChanged so you can determine if the current view is in the ActiveViews or not. 

HTH,

-b



Thanks for the answer, i think i will do this by implement the IActiveAware interface in View implementations as it looks like working pretty well :)