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 George,
I am just checking, if you got this working, or if you require any further clarification on the matter.
I have checked your modification and you I see a few binding errors in your output window. This has nothing to do with the approach being wrong or, the assemblies being built under a different version of .Net. This happens because all these binding don’t have the same path as you have assumed. You can use an I value converter to check the DataContext value that comes for each Binding, if that is how you have decided to use them. Another thing you can do is use a relative source binding to make sure all path start from your CellValuePresenter like:
<Style TargetType="{x:Type igDP:CellValuePresenter}"> <!--To color --> <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.SelectedRowForeground}"/> <!--To color on cell activation --> <Setter Property="ForegroundActiveStyle"> <Setter.Value> <Style> <Setter Property="TextElement.Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Path=Record.DataItem.SelectedRowForeground}" /> </Style> </Setter.Value> </Setter>..
(the latter binding is reused throughout the rest of the style)
Please let me know, if you require any further clarifications on the matter.
Hi Petar,
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 worked out, or you still require any assistance, or clarification on the matter.
I have been looking into this for you and since, I couldn’t think of what might cause this in the scenario you described, I have made a test sample based on your description (Grid_complex_property.zip) and everything seems to work as expected. I suppose there is something else in your project that is causing this.
Please let me know, if can be of any further assistance on the matter.