WPF对象如何将自己作为MultiBinding路径发送

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可以使用它。

感谢任何帮助。

1个回答

17

哇,我瞎猜了一下居然成功了 =S 哈哈,这是解决方案

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

谢谢!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接