Parent-Child SimpleCommand accessing

Sep 15, 2010 at 1:29 PM

Hi Sacha,

I'm updating my project to V2 WPF and looking to rewrite some parts of my code which are horrible...!

Main window has a ribbon control with tabs, Home / Configuration etc which opens its own workspace with only TabControlEx control.

private void ViewAwareStatusService_ViewLoaded()
{
    HomeWorkspace = new WorkspaceData(null, "HomeView", null, "Home View", true);
    ConfigWorkspace = new WorkspaceData(null, "ConfigView", null, "Config View", true);
}

ConfigViewModel has the SimpleCommands for its section on the Ribbon Tab: Edit Customers, View Orders etc

CustomerCommand = new SimpleCommand<Object, EventToCommandArgs>(ExecuteCustomerViewEventToVMFiredCommand);
OrdersCommand = new SimpleCommand<Object, EventToCommandArgs>(ExecuteOrdersViewEventToVMFiredCommand);
...
private void ExecuteOrdersViewEventToVMFiredCommand(EventToCommandArgs args)        
{
        WorkspaceData ws = new WorkspaceData(@"/OpS;component/Images/Basket.png", "OrdersView", null, "Orders View", true);
        Views.Add(ws);
        SetActiveWorkspace(ws);
}
 
How can I bind the buttons on the Main Window, to the SimpleCommands in ConfigViewModel.
OR is there another way I'm not seeing? Or maybe I'm just over complicating things!!
Ribbontabs workspace is changed like so
<ContentControl Content="{Binding HomeWorkspace}" Visibility="{Binding ElementName=Home, Path=IsSelected, Mode=TwoWay, Converter={StaticResource BoolToVisConverter}, ConverterParameter=True}" />
<ContentControl Content="{Binding ConfigWorkspace}" Visibility="{Binding ElementName=Config, Path=IsSelected, Mode=TwoWay, Converter={StaticResource BoolToVisConverter}, ConverterParameter=True}" />
I have a couple of images that may explain this better if that helps??
 
Alex
 
 
 
Sep 15, 2010 at 5:09 PM

I don't quite get your arrangement, but could you not use Mediator to message from MainWindow to ConfigViewModel, does that not work for you. Where are Ribbon Commands, in Window code behind? In which case I would use Mediator I think.