Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9157045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:55:01+00:00 2026-06-17T12:55:01+00:00

How can I use DataTriggers in a DataGridColumHeader? With this code below it doesn’t

  • 0

How can I use DataTriggers in a DataGridColumHeader? With this code below it doesn’t work. Someone got any idea how i can fix this?

<DataGridTextColumn.HeaderStyle>
   <Style TargetType="{x:Type DataGridColumnHeader}">
     <Setter Property="Background" Value="#FFFFBD21" />
     <Style.Triggers>
      <DataTrigger Binding="{Binding HasChangedRows}" Value="false">
        <Setter Property="Background" Value="#66FFBD21"/>
      </DataTrigger>
    </Style.Triggers>
  </Style>
</DataGridTextColumn.HeaderStyle>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:55:03+00:00Added an answer on June 17, 2026 at 12:55 pm

    Check This Code in a new solution and you will see that it should work if HasChangedRows Binding is correctly set. You can use the checkbox to change the value of HasChangedRows

    <Window x:Class="WpfApplication10.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        
        Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
    <StackPanel>
        <CheckBox IsThreeState="False" IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=HasChanges, Mode=TwoWay}"
                  Content="{Binding RelativeSource={RelativeSource Mode=Self}, Path=IsChecked}"/>
    
        <DataGrid Name="MainGrid" AutoGenerateColumns="False">
            <DataGrid.Resources>
                <Style TargetType="{x:Type DataGridColumnHeader}" x:Key="customheaderstyle">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=HasChanges}" Value="false">
                            <Setter Property="Background" Value="#66FFBD21"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=HasChanges}" Value="true">
                            <Setter Property="Background" Value="#FFFFBD21" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </DataGrid.Resources>
            <DataGrid.Columns>
                <DataGridTextColumn HeaderStyle="{StaticResource customheaderstyle}" Binding="{Binding}"/>
            </DataGrid.Columns>
        </DataGrid>
    </StackPanel>
    </Window>
    

    and code behind:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.ComponentModel;
    
    namespace WpfApplication10
    {
      public partial class MainWindow : Window, INotifyPropertyChanged
      {
    
       #region INotifyPropertyChanged
    
        public event PropertyChangedEventHandler PropertyChanged;
        protected void NotifyPropertyChange(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    
        #endregion
    
    
        private bool _HasChanges = false;
        public bool HasChanges
        {
            get { return this._HasChanges; }
            set
            {
                this._HasChanges = value;                
                NotifyPropertyChange("HasChanges");
    
            }
        } 
    
        public MainWindow()
        {
            InitializeComponent();
        }
    
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            String[] list = { "1", "2", "3", "4" };
            this.MainGrid.ItemsSource = list;            
        }
      }
    }
    

    Final result:

    enter image description here

    And

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can use select into with multiple cte? for example in the below code the
I can use this maven plugin maven-jaxb-plugin to generate Java Classes from XSD file.
I can use the PRINT statement in a stored procedure to debug my code.
I can use .map(func) on any column in a df, like: df = DataFrame({'a':[1,2,3,4,5,6],
I've been stuck on this for a while now and I can't work out
We can use the web worker in HTML5 like this: var worker = new
We can use Wait and Pulse to simulate a ManualResetEvent as follows: code #1
Can i use the SqlAlchemy ORM-Mapper to only generate the SQL-Code? With simple tables
Any Assumption or rule is there, when we can use DataTrigger and when we
I can use the following to get the contents of a folder with no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.