Managing state of buttons and menu items

Topics: Prism v4 - Silverlight 4, Prism v4 - WPF 4
Jan 22, 2012 at 7:47 AM

I am looking for some patterns and infrastructure for helping me manage state of buttons and menu items in a composite application.

I have a shared ribbon bar with shared commands and each module injects additional button and menus

When an item is selected in a module I need to enable some shared items and disable others

What is the suggested approach?

My current thinking is the following

Every View Model which can handle commands from the ribbon bar will define those commands

The commands state  implementation(CanExecute) will forward state management to the ribbon commands

through ashared service

Thanks in advance

Jan 23, 2012 at 5:57 PM


Based on my understanding of your scenario, I believe you might benefit from the IActiveAware interface, which can be implemented on child views or view models. This interface is primarily used to track the active state of a child view within a region. This way when a view is selected, you could react updating the status of the corresponding commands, for example using a shared service as you mentioned.

Additionally DelegateCommand class also implements the IActiveAware interface, which can be useful if you are using CompositeCommands, as these can be configured to evaluate the active status of child DelegateCommands (in addition to the CanExecute status) allowing to define which child commands CanExecute status will be considered when enabling the shared command.

If this approach is useful for your scenario, you can find more related information about in the following links:

Also, I believe you might find the following threads interesting:

I hope you find this handy,

Agustin Adami

Jan 27, 2012 at 9:46 AM

Thanks.i will give it a try.