开发者

WPF Object send itself as MultiBinding path

开发者 https://www.devze.com 2022-12-12 02:20 出处:网络
Basically what I need to know is how to send the source of an HierarchicalDataTemplate into a binding, this is what I have:

Basically what I need to know is how to send the source of an HierarchicalDataTemplate into a binding, this is what I have:

<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 Co开发者_如何学JAVAnverter="{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>

So my source is an object of type myModel:Person, I want to be able to send the object itself in the MultiBinding so the PersonConverter can use it.

Thanks for any help.


Wow, I did a crazy wild guess and it worked =S lol, here's the solution

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

Thanks!

0

精彩评论

暂无评论...
验证码 换一张
取 消