Toolbar status and events to current tabitem

Nov 14, 2011 at 4:47 PM

Hi All,

lets have some views in a tabcontrol. each view is represented by his own tabitem.

Lets also have a toolbar with entrys like "Edit", "Save", "Undo" and so on.

Be so kind and give me a tip how can i realize:

=> The toolbar items should be enabled/disabled due to the state of the view in the current tabitem - also if a tabselectionchange occurs or the view change his state

=> How can i pass the command of an enabled toolbaritem to the active view

I am searching for the relevant prism-way. Hardcoded (strange) will be no problem ;-)

Regards and thanks for help and time

Nov 14, 2011 at 8:59 PM


The details of how to implement this depends mostly of your personal preferences and the requirements of your scenario.

As possible approach you could do something like this:

  • First, make the views or the view models that are going to be injected in the TabControl implement the IActiveAware interface. With this, those views or view models can know when their are being activated or deactivated.
  • Then, create a Shared Service that you can use to store the state of the items in the toolbar.
  • When the a view is activated, you could use the shared service to change the state of the items in the toolbar. You could either change the state directly in the view / view model, or "inform" the shared service of the activation of the view, and make the changes in the service. This depends mostly of your personal preferences.
  • Also, you could "pass" a command from the toolbar to the view / view model using a similar approach.

I hope you find this useful,

Damian Cherubini