I am using autogenerating datagrid and binding it to a DataTable.This DataTable has columns with whitespaces like 'Last Value'. Now I need to add a datatrigger to apply some style as shown below:
<DataGrid.Resources>
<Style x:Key="DgStyle" TargetType="{x:Type TextBlock}">
<Setter Property="TextAlignment" Value="Right"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Last Value, Converter= {StaticResource DecimalToBoolConverter}}" Value="True">
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
But DataTrigger Binding doesn't support whitespaces (Last Value). When I remove the whitespace(LastValue) then it works fine. But as per my requirement I need whitespace in the datatable columns name and this table is being used to bind datagrid.
How could I handle this scenario? Please suggest.
Good question!
You can use single quote on the property name.
Binding={Binding 'Last Value', Converter= {StaticResource DecimalToBoolConverter}}"