WPF object sends itself as a MultiBinding path

Basically, I need to know how to send the source HierarchicalDataTemplateto the 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 to MultiBinding, so I PersonConvertercan use it.

Thanks for any help.

+3
source share
1 answer

Wow, I made a crazy wild guess and it worked = S lol, here is the solution

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

Thanks!

+12
source

Source: https://habr.com/ru/post/1723711/


All Articles