4

基本的に私が知る必要があるのは、のソースをHierarchicalDataTemplateバインディングに送信する方法です。これは私が持っているものです:

<HierarchicalDataTemplate DataType="{x:Type myModel:Person}">
    <StackPanel Orientation="Horizontal">
        <Image Source="Images\User.gif" />
        <TextBlock Margin="5,0,0,0" Text="{Binding Name}" />
    </StackPanel>
    <HierarchicalDataTemplate.ItemsSource>
        <MultiBinding Converter="{StaticResource PersonConverter}">
            <Binding Path="Name" />
            <!-- Here I need something like Binding Path="Self" so I can send the source of the binding (the "Person" object) -->
        </MultiBinding>
    </HierarchicalDataTemplate.ItemsSource>
</HierarchicalDataTemplate>

したがって、私のソースは type のオブジェクトです。オブジェクト自体を に送信して、が使用myModel:Personできるようにしたいと考えています。MultiBindingPersonConverter

助けてくれてありがとう。

4

1 に答える 1

16

うわー、私はクレイジーでワイルドな推測をしましたが、うまくいきました= S笑、これが解決策です

<MultiBinding Converter="{StaticResource PersonConverter}">
    <Binding Path="Name" />
    <Binding Path="." /> <!-- this sends the source of the binding -->
</MultiBinding>

ありがとう!

于 2009-11-23T21:20:40.757 に答える