Silverlight / WPF - Using ConverterParameter in xaml

Asked By Amit K on 25-Nov-15 12:35 AM
Hi,

I've a datagrid in my xaml:
<dg:DataGridTextColumn Header="A" Width="110" Binding="{Binding ValueA, StringFormat=N2}"  IsReadOnly="true" FontWeight="Bold">
                            <dg:DataGridTextColumn.CellStyle>
                                <Style TargetType="dg:DataGridCell">
                                    <Style.Triggers>                                        
                                        <DataTrigger Binding="{Binding ValueA, Converter={StaticResource MyConverterA}}" Value="True">
                                            <Setter Property="Background" Value="LightYellow"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </dg:DataGridTextColumn.CellStyle>
</dg:DataGridTextColumn>
                        


<dg:DataGridTextColumn Header="B" Width="180" Binding="{Binding B, StringFormat=N2}"  IsReadOnly="true" FontWeight="Bold">
                            <dg:DataGridTextColumn.CellStyle>
                                <Style TargetType="dg:DataGridCell">
                                    <Style.Triggers>                                        
                                        <DataTrigger Binding="{Binding MyVal, Converter={StaticResource MyConverterB}, ConverterParameter=??}" Value="True">
                                            
                                            <Setter Property="Background" Value="Red"/>
                                        </DataTrigger>                                       
                                    </Style.Triggers>
                                </Style>
                            </dg:DataGridTextColumn.CellStyle>
                        </dg:DataGridTextColumn>


I need to pass value of COlumn "A" as a parameter to MyConverterB, using ConverterParameter.
Any pointers pleasse?

Thanks for your help. 
Robbe Morris replied to Amit K on 25-Nov-15 07:09 PM
I'll be honest, I have not spent any serious time with WPF for almost two years now but I don't think you can bind the ConverterParameter.  I seem to recall this being an issue.  At least with early versions of WPF.

I can tell you how to programmatically alter the binding and its parameters at runtime though.  Perhaps that can help if you cannot find a better solution.

https://www.nullskull.com/a/954/wpf--silverlight-dynamically-change-data-binding-attributes-at-runtime.aspx