基本上我需要知道的是如何将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
可以使用它。
感谢您的帮助。
答案 0 :(得分:12)
<MultiBinding Converter="{StaticResource PersonConverter}">
<Binding Path="Name" />
<Binding Path="." /> <!-- this sends the source of the binding -->
</MultiBinding>
谢谢!