I'm trying to change the Foreground color of a row by adding a style to CellValuePresenter using the following code:
<Style TargetType="{x:Type igDP:CellValuePresenter}" > <Setter Property="Foreground" Value="Red/></Style>-->
It works fine as long as nothing changes in the row, but whenever I move with the mouse over that row the foreground color changes back to black.
I tried setting the rest of the Foreground properties to null in the same style (ForegroundHover, ForegroundSelected, etc) but it didn't work.
Any Idea?
Hello,
Excuse me for the late reply. I have created a style for the CellValuePresenter for you that sets all the foreground properties and states I could think of:
<SolidColorBrush Color="YellowGreen" x:Key="CVPOverallForeground" />
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<!--To color -->
<Setter Property="Foreground" Value="{StaticResource CVPOverallForeground}"/>
<!--To color on cell activation -->
<Setter Property="ForegroundActiveStyle">
<Setter.Value>
<Style>
<Setter Property="TextElement.Foreground" Value="{StaticResource CVPOverallForeground}" />
</Style>
</Setter.Value>
</Setter>
<!--To color on cell hover-->
<Setter Property="ForegroundHoverStyle">
<!--To color on cell selection (no hover)-->
<Setter Property="ForegroundSelectedStyle">
<Style.Triggers>
<!--To color on record selection-->
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.IsSelected}" Value="True">
<Setter Property="ForegroundStyle">
</DataTrigger>
<!--To color on record hover (no selection) -->
<Trigger Property="IsMouseOverRecord" Value="True">
</Trigger>
</Style.Triggers>
Please let me know if I have missed out something or if you require any further assistance on the matter.
Sincerely,
Petar Monov
Developer Support Engineer
Infragistics Bulgaria
www.infragistics.com/support
Hi Petar,
Unfortunately this solutiuon doesn't work for columns / fileds bound to properties with custom types. For example:
<dp:Field Name="RequestTime" />
It's bound to the property in a view model:
public DateTimeViewModel RequestTime
Where DateTimeViewModel is a custom class with overriden ToString() method.
Can you advise how to fix it in this case? Thanks.
Hello George,
I am just checking if you got this worked out, or you still require any assistance, or clarification on the matter.
The problem arises when a foreground brush is a property of an actual item, not a static resource. In your sample it will be:
public class MyParentClass
{
public MyClass MyClassProperty { get; set; }
public Brush SelectedRowForeground { get; set; }
}
And in XMAL it's bound as:
<Setter Property="TextElement.Foreground" Value="{Binding DataItem.SelectedRowForeground}" />
Also InfragisticsWPF3 must be used (still on .NET 3.5)
Please see attachment.
I am just checking, if you got this working, or if you require any further clarification on the matter.