1

Is it possible to use CommandParameter="{Binding}" in a multi binding? I am trying to do this in a data grid.

<CheckBox.CommandParameter>
    <MultiBinding Converter="{StaticResource CDetailConverter}">
        <Binding Path ="IsChecked" ElementName="chkSelection"/>                                        
        <Binding ConverterParameter="{Binding}"/>
    </MultiBinding>
</CheckBox.CommandParameter>

The second Binding throws an error.

2
  • Converter parameter is not a Dependency property so you cannot Bind something to it.... what are you trying to do any way ?? Commented Nov 28, 2011 at 4:16
  • Protip: No need to put tags in titles, and "throws an error" is practically useless without the actual exception type and message. In this case, you were lucky that the whole converter requirement for multibinding command parameters is well known. In future, it may result in you not getting any answers to your questions! Commented Nov 28, 2011 at 12:54

1 Answer 1

2

In a nutshell, the answer is no.

In your second inner Binding you have set ConverterParameter. There are a couple of problems with this:

First, Binding is its own class separate from MultiBinding with both Converter and ConverterParameter properties. Here you have set the ConverterParameter property without setting the Converter property. Remember that ConverterParameter is passed to the Binding's specified converter regardless if it is used within a MultiBinding or not. If you were to add a Converter here, then the converter would be passed the specified ConverterParameter.

What you probably meant to do was set the ConverterParameter on the outer MultiBinding which also has this property:

<CheckBox.CommandParameter>
    <MultiBinding Converter="{StaticResource CDetailConverter}" ConverterParameter="{Binding }">
        <Binding Path ="IsChecked" ElementName="chkSelection"/>                                        
    </MultiBinding>
</CheckBox.CommandParameter>

If you try this, you will quickly see that ConverterParameter can not be the target of a Binding expression since it is not a DependencyProperty.

Since you can not bind to CommandParameter, the typical workaround is to modify your IMultiConverter to accept an additional value, and supply this value through a binding expression:

<CheckBox.CommandParameter>
    <!-- CDetailConverter updated to expect an additional value in the values array -->
    <MultiBinding Converter="{StaticResource CDetailConverter}">
        <Binding Path ="IsChecked" ElementName="chkSelection"/>
        <Binding />                                   
    </MultiBinding>
</CheckBox.CommandParameter>

Hope this helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.