Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ConverterParameter with Binding on Multibinding

is it possible to add a Binding to a ConverterParameter in a MultiBinding? Something like this:

    <HierarchicalDataTemplate DataType="{x:Type Elements:RootElement}">
        <HierarchicalDataTemplate.ItemsSource>
            <MultiBinding Converter="{StaticResource filterConverter}" ConverterParameter="{Binding IsFilterd}">
                <Binding Path="Children"/>
                <Binding Path="FilterChildren"/>
            </MultiBinding>
        </HierarchicalDataTemplate.ItemsSource>
        <TextBlock Text="{Binding Name}" FontWeight="Normal"/>
    </HierarchicalDataTemplate>

Where IsFiltered is a Property on the Object that the Template is applied on. I always get an XAML parser error that the Binding is not correct/allowed in ConverterParameter... Or is there some other way to do this??

Greets,

Jürgen

like image 521
opiswahn Avatar asked Apr 01 '11 14:04

opiswahn


2 Answers

ConverterParameter is not a DependencyProperty, and therefore databinding can't work on it.

Why not add another Binding to the MultiBinding? send the IsFiltered as another value:

        <MultiBinding Converter="{StaticResource filterConverter}" >
            <Binding Path="Children"/>
            <Binding Path="FilterChildren"/>
            <Binding Path="IsFiltered" />
        </MultiBinding>
like image 194
Elad Katz Avatar answered Nov 16 '22 10:11

Elad Katz


Just add the ConverterParameter the way I did it in the code below, if you have plain text to pass to the multiconverter.

<MultiBinding Converter="{StaticResource SortingDirectionImageMultiConverter}">
    <Binding Path="SortingColumnIdentifier"/>
    <Binding Path="IsSortingAscending"/>
    <MultiBinding.ConverterParameter>txtBlockConfigNumber</MultiBinding.ConverterParameter>
</MultiBinding>
like image 32
Michael Bernhard Avatar answered Nov 16 '22 10:11

Michael Bernhard