ページビューとツリービューがあります。私はMVVMを使用しています。
私のページが私のデータ ビューモデル データ コンテキストを使用しているとします。ツリー ビューは、ビュー モデル内の別のパブリック オブジェクトにバインドされています。ツリー アイテム内で、コマンドをページ ビュー モデルにバインドしたいと考えました。xaml で参照するにはどうすればよいですか?
以下のコード。
<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>
どんな助けでも大いに感謝します!