I have a page and tree view. I am using MVVM.
Say my page is using my data viewmodel data context. My tree view is binded to another public object in my view model. Now inside my tree item, I wanted to bind the command in the page view model. How do I refer in the xaml?
code below.
<TreeView  Style="{StaticResource MyNodeStyle}" 
        ItemsSource="{Binding {**Object in Page ViewModel**)}"   
        ItemContainerStyle="{StaticResource TreeViewItemStyle}"  
        ScrollViewer.HorizontalScrollBarVisibility="Hidden"  
        DockPanel.Dock="Bottom" Height="440">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Connections}" 
                        ItemContainerStyle="{StaticResource ResourceKey=TreeViewItemConnectionStyle}" >
    <WrapPanel>
        <CheckBox  VerticalAlignment="Center" 
                Command="{Binding {**Command in Main Page View Model** }}"    
                IsChecked="{Binding Status,  Mode=TwoWay}" 
                Focusable="False"  
                Style="{StaticResource ResourceKey=TreeView_CheckBox_Style}"  >
        </CheckBox>
        <TextBlock Text="{Binding Name}"  Style="{StaticResource ResourceKey=treeTextBoxStyle}" />
    </WrapPanel>
Any help greatly appriciated!
 
                        
If you are using Josh Smith's
RelayCommandclass, then the commandWhere
SomeMethodisand the object
owill hold theCheckBoxes state (IsChecked). Now the binding you want to use iswhere the
CommandParameter="{Binding RelativeSource={RelativeSource Self}}"is passing theIsCheckedstate into your command via the objecto.i hope this helps.