Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Applying CellValuePresenterStyle breaks funtionality

I am applying a style to CellValuePresenter but when the row is highlighted or selected the style is ignored. For example, I am using the following XAML to change the foreground color when it contains a specific value. It works until the user rolls the mouse over the row or selects it. Then the style is ignored.

<Window x:Class="XamChildGridLabel.MainWindow"
        DataContext="{Binding RelativeSource={RelativeSource Self}}"
        Title="MainWindow" Height="350" Width="525">
        <igDP:XamDataGrid DataSource="{Binding Level1}" GroupByAreaLocation="None">
                <igDP:FieldSettings AllowSummaries="False" SummaryUIType="SingleSelect" LabelTextAlignment="Center" AllowEdit="False"/>
                <igDP:FieldLayout Description="Level 1" Key="Level1">
                        <igDP:TextField Label="Text" Name="Text">
                                <Style TargetType="igDP:CellValuePresenter">
                                        <DataTrigger Binding="{Binding DataItem.Text}" Value="Text 1">
                                            <Setter Property="Foreground" Value="Red"/>

namespace XamChildGridLabel

    public partial class MainWindow : Window
        public class cLevel1
            public String Text { get; set; }
            public cLevel1(String t)
                this.Text = t;

        public List<cLevel1> Level1 { get; set; }

        public MainWindow()
            Level1 = new List<cLevel1>() { new cLevel1("Text 1"), new cLevel1("Text 2") };

No Data
  • 28530
    Verified Answer
    Offline posted

    Hello Terry,

    I have been investigating into this behavior you are seeing, and there are quite a few different properties on the CellValuePresenter that effect the foreground color depending on the state of the cell or the record that owns the cell. For example, there is the ForegroundHoverStyle, ForegroundSelectedStyle, etc. properties.

    In the CellValuePresenter, these properties expect a Style targeting ContentPresenter, in which you can use a Setter to set the TextElement.Foreground property to have it applied. I would recommend setting these different properties to further control the foreground of your cells. I am attaching a sample project to demonstrate usage of these properties to prevent foreground color changes on hover, selection, and activation. I hope it helps you.

    Please let me know if you have any other questions or concerns on this matter.