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>

所以我的源是一个类型的对象myModel:Person,我希望能够发送对象本身,MultiBinding以便PersonConverter可以使用它。

谢谢你的帮助。

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 回答