Changing the foreground color of a DataGrid row based on property

Hello Experts, hoping someone could show me what I'm doing wrong. Note: my code does run and I experience no errors AND code execution breaks in the Value Converter, but does not change the color of the cell as anticipated.

Overview: I am loading some pallets into a DataGrid. If Quality Control is completed I want the text to be black. If Quality Control is needed, then I want the foreground to be Red. Also because I have multiple bindings going on, I decided against using the ElementStyle and instead am trying to use a DataGridTemplate.

Any help would be appreciated.

Warm regards,

// Color Converter ---------------------------------------------------

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace MBGQuality.Converters
    class ColorConverter : IValueConverter
        public static readonly IValueConverter Instance = new ColorConverter();
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            bool IsQCDone = (bool)value;

            if (IsQCDone == true)
                return Brushes.Black;

            if (IsQCDone == false)
                return Brushes.Red;

            return Brushes.Transparent;
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            throw new NotImplementedException();

// LookupPallet.xaml ---------------------------------------------------

<DataGrid Name="dgPallets" HorizontalAlignment="Left" Height="207" Margin="15,165,0,0" VerticalAlignment="Top" Width="528" AutoGenerateColumns="False" HorizontalScrollBarVisibility="Disabled" SelectionMode="Single" IsReadOnly="True" IsSynchronizedWithCurrentItem="True">
      <DataGridTemplateColumn Header="Pallet" Width="125" >
                        <TextBlock Text="{Binding Path= pPallet}" FontSize="16" Foreground="{Binding IsQCDone, Converter={StaticResource ColorConverter},RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
      <DataGridTextColumn Binding="{Binding Path= Product}" Header="Product" Width="250" FontSize="16" />    
      <DataGridTextColumn Binding="{Binding Path= dDate, StringFormat='MM/dd/yyyy'}" Header="Date" Width="150" FontSize="16"/>              

// LookupPallet.xaml.cs ---------------------------------------------------

private bool _isQCDone;
public bool IsQCDone
      get { return _isQCDone; }

            _isQCDone = value;

private void LookupPallet_Loaded(object sender, RoutedEventArgs e)
      IsQCDone = false; // <-- setting property here manually for now

      this.Left = 0;
      this.Top = 5;
      dpDate.Text = ptq.TodayDate.ToShortDateString();

private void GetData()
      if (dpDate == null)
      if (ptq.Pallet.Type == 2)          
            dsPallets = ptc.pkr_Packed_List(2, 0, DateTime.Parse(dpDate.Text), ptq.Month);      
      if (ptq.Pallet.Type == 6)            
            dsPallets = ptc.pkr_Receipts_toQC_get();    

      // set up view using dataset and set itemsource to dataview
      dvPallets = new DataView(dsPallets.Tables[0]);
      dgPallets.ItemsSource = dvPallets;
James Young jyoung@blueberries.comSr. Applications DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

James Young jyoung@blueberries.comSr. Applications DeveloperAuthor Commented:
Decided to go with a DataGrid.RowStyle and DataTrigger for my solution. While I only wanted the Pallet number to be red, targeting a single column, our team is fine coloring the row. Works like a charm.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
James Young jyoung@blueberries.comSr. Applications DeveloperAuthor Commented:
Figured it out myself.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.