ConverterParameter with Binding on Multibinding

opiswahn picture opiswahn · Apr 1, 2011 · Viewed 19.4k times · Source

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

Answer

Elad Katz picture Elad Katz · Apr 1, 2011

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>