Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Any one please suggest me a way to bind the command across the view models other than using Messenger.
Please find my code below.
I need to bind the command of MenuItem with RelayCommand property which exists in other view model.
Below is the way I tried out.it doesnot however.

XML
<igDock:ContentPane Header="Dashboard" x:Name="dashboardWindow" DataContext="{Binding Path=viewModels:DashboardViewModel.}"  AllowClose="False">
                                  <ContentControl Content="{Binding ElementName=panelUI, Path=DashboardControl, Mode=TwoWay}"/>
                                  <ContentControl.ContextMenu>
                                      <ContextMenu>
                                          <MenuItem  Header="Add New Tile" Command="{Binding ElementName=dashboardWindow,Path=viewModels:DashboardViewModel.AddTileContextMenuCommand}"></MenuItem>
                                      </ContextMenu>
                                  </ContentControl.ContextMenu>
                              </igDock:ContentPane>
Posted
Comments
AnthonyMG 27-Nov-13 11:50am    
you need to have a single Command binding for all your VM's ?
Sreepada1005 28-Nov-13 0:57am    
Yes.I used single command in one viewmodel which i need to bind in two different windows

1 solution

Hey ...

My problem got solved.

I just assigned the dashboardWindow DataContext with my view model.
I could get the command in my window. :)
 
Share this answer
 
Comments
AnthonyMG 28-Nov-13 2:15am    
Good :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900