Hi
I net to change the fore color of a cell value if the value is over 100. I create all of my fields ar not created in the xaml. I create the fields at the FieldLayoutInitialized event handler.
Dim oHookUtilizationField As New Field With {.Name = HOOKUTILIZATION, .Label ="Utilization", Column = 2, .Row = 1, .Width = m_oColumnWidth}
e.FieldLayout.Fields.Add(oHookUtilizationField)
Now i need to change the fore color of this field if the value is over 100 i have only found xaml solution for my problem like this:
<igDP:Field.Settings>
<igDP:FieldSettings EditorType="{x:Type igEditors:XamCurrencyEditor}" EditAsType="{x:Type System:Double}">
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:ValueEditor}">
<Style.Setters>
<Setter Property="ValueConstraint">
<Setter.Value>
<igEditors:ValueConstraint MinInclusive="0" MaxInclusive="100" />
</Setter.Value>
</Setter>
<Setter Property="InvalidValueBehavior" Value="RetainValue" />
</Style.Setters>
<Style.Triggers>
<Trigger Property="IsValueValid" Value="false">
<Trigger.Setters>
<Setter Property="ForeColor" Value="Red" />
</Trigger.Setters>
</Trigger>
</Style.Triggers>
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
I need this code at the FieldLayoutInitialized event handler.
Hello,
I have modified your sample, so now it works as expected. Basically I changed the Binding Path to “Value”, because since the RelativeSource is Self the DataContext is CellValuePresenter and we need its Value Property.
Hope this helps you.
Hello Stefan
Thank you for the fast reply. I tried your solution in my project but it didn't work. I think the problem is that my source is a generic list filled with my own class items. I modified the test project that you can see the problem.
I have been looking into you sample and I modified it, so now it works as you want. Basically I changed the Brushes you return in the converter, because the WPF applications use Brushes from System.Windows.Media namespace, while the one you used were from System.Drawing namespace.
I tried it with your solution it owrks perfect if the application is a wpf appliaction. This soultion does not work in my project i habe a windows form application with an element host. The element host shows my wpf usercontrol with the wpf grid. I created a sample project for you so that you can see the problem.
There is a purple link called “XamDataGridConditionlFormatting.zip” just below my name, in my previous post.