Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Object send itself as MultiBinding path

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

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.

like image 890
Carlo Avatar asked Dec 08 '22 05:12

Carlo


1 Answers

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!

like image 197
Carlo Avatar answered Dec 11 '22 09:12

Carlo