Binding value as ConverterParameter
In my resourceDictionary, I have the following style:
<Style TargetType="{x:Type propgrid:PropertyGridDataAccessorItem}" x:Key="{x:Type propgrid:PropertyGridDataAccessorItem}">
<Style.Triggers>
<Trigger Property="DataAccessorType" Value="Category">
<Setter Property="IsExpanded" Value="{Binding DisplayName, Converter={local:ExpandedCategoryConverter}}"/>
</Trigger>
</Style.Triggers>
</Style>
I need to bind the value from my viewModel to ConverterParameter, something like ConverterParameter = {Binding MyProperty}, but we cannot bind to ConverterParameter.
How can I solve this problem?
Thnx in advance
0
source to share
1 answer
As you discovered, you cannot bind ConverterParameter
because it is not a dependency property.
In most cases, the solution to this is to simply use a multivalued converter instead of MultiBinding
and , for example:
<Trigger Property="DataAccessorType" Value="Category">
<Setter Property="IsExpanded">
<Setter.Value>
<MultiBinding Converter="{local:ExpandedCategoryConverter}">
<Binding Path="DisplayName"/>
<Binding Path="WhatYouWantToPassInAsConverterParameter"/>
</MultiBinding>
</Setter.Value>
</Setter>
</Trigger>
The converter must of course be updated accordingly.
+4
source to share