1

にバインドされDelegateCommandたアイテムにWPF を追加するにはどうすればよいですか? 私はMVVMパターンとコンポジットWPFを使用しています.ユーザーが.TreeViewXmlDataProviderTreeView


に設定されているTreeViewXAMLで定義されています:DataContextXmlDataProvider

<TreeView
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    ItemsSource="{Binding XPath=/SomeTopElement/*}">
    <TreeView.Resources>
        <HierarchicalDataTemplate
            DataType="SomeElement"
            ItemsSource="{Binding XPath=child::*}">
            <TextBlock Text="{Binding XPath=@SomeAttribute}" />
        </HierarchicalDataTemplate>
    </TreeView.Resources>
</TreeView>

コードの他の部分ではDelegateCommand、ViewModel の にバインドするだけです。

<MenuItem Command="{Binding NewCommand}" Header="_New" />

上記でこれを行うにはどうすればよいTreeViewですか?

4

1 に答える 1

2

Attached Command Behavior パターンを使用する必要があります。この質問は同様の問題に答えますが、ListView 内にあります。

于 2009-07-22T12:50:20.540 に答える