I have a composite WPF application. I am planning to implement tool bar functionality . There are few toolbar items ( basically print,save , hide , expand , undo) which will be common to all views in the main region. For this i have created default toolbar module which will add these items ( print,save , hide , expand , undo) to the toolbar region. when user clicks any toolbar item , this need to be handled by all 20 views in the main region.
For each toolbar item , i have associated a prism delegatecommand object.
sample: private ICommand _printCommand;
public ICommand PrintCommand
{
get
{
if (_printCommand == null)
{
_printCommand = new DelegateCommand(Print, CanPrint);
}
return _printCommand;
}
}
Xaml , bind toolbar item to this command.
In the main region , we display close to 20 views. All these views have to subscibe to this command. I am thinking of using event aggregator to publish an event , and all the views will subcribe to this event.
For ex: when the user clicks print , print command executes Print method which will publish print event. This event will be subcribed by 20 views and do further processing.
Am i implementing toolbar in the rtight way?