Reputation: 1813
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.
Upvotes: 1
Views: 1340
Reputation: 3285
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!
Upvotes: 2