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 697075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:07:51+00:00 2026-05-14T03:07:51+00:00

Lets say I have 2 columns in my data Grid: Column A: Selected, and

  • 0

Lets say I have 2 columns in my data Grid: Column A: Selected, and Column B: Name. The Selected column is a checkbox. And Name column is text field. I want to set the color of the text in ‘Name’ column as Blue if Column A’s check box is checked, and Red otherwise.

Essentially I don’t know how to bind data between columns of the datagrid. And sample code/link providing example would be useful.

  • 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-05-14T03:07:51+00:00Added an answer on May 14, 2026 at 3:07 am

    I haven’t used the WPF Toolkit’s DataGrid much, but from what I can gather, one method is to use DataGridTemplateColumn’s and then set up your DataTriggers based on the binding.

    Here is an example that uses DataTriggers to set the style of the Foreground color as well the entire row’s background color. Of note, you’ll need a boolean Property in your ItemsSource’s binding to make this work with this method.

    XAML

    <Window.Resources>
    
    <Style TargetType="{x:Type tk:DataGridRow}">
        <Style.Triggers>
            <DataTrigger 
                Binding="{Binding Path=IsSelected}" Value="True">
                <Setter Property="Background" Value="Yellow" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
    
    <Style TargetType="{x:Type TextBlock}" x:Key="MyTextBlockStyle">
        <Style.Triggers>
            <DataTrigger 
                Binding="{Binding Path=IsSelected}" Value="True">
                <Setter Property="Foreground" Value="Blue" />
            </DataTrigger>
            <DataTrigger 
                Binding="{Binding Path=IsSelected}" Value="False">
                <Setter Property="Foreground" Value="Red" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
    
    
    </Window.Resources>
    <Grid>
    <tk:DataGrid x:Name="MyGrid" 
                 AutoGenerateColumns="False"
                 ItemsSource="{Binding}">
        <tk:DataGrid.Columns>
    
            <tk:DataGridTemplateColumn Header="Selected"
                                       Width="75">
                <tk:DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                         <CheckBox IsChecked="{Binding Path=IsSelected}"/>
                    </DataTemplate>
                </tk:DataGridTemplateColumn.CellTemplate>
            </tk:DataGridTemplateColumn>
    
            <tk:DataGridTemplateColumn Header="Name" Width="100" >
                <tk:DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=Name}" 
                                   Style="{StaticResource MyTextBlockStyle}" />
                    </DataTemplate>
                </tk:DataGridTemplateColumn.CellTemplate>
            </tk:DataGridTemplateColumn>   
    
        </tk:DataGrid.Columns>
    </tk:DataGrid>
    
    </Grid>
    

    Code Behind

    public partial class DataGridDataTrigger : Window
    {
        public List<Person> People { get; set; }
        public DataGridDataTrigger()
        {
            InitializeComponent();
    
            var names = new List<string> { "Joe", "Bob", "Frank", "Scott", "Mike" };
            People = new List<Person>();
            names.ForEach( x => People.Add( new Person { Name = x } ) );
    
            People.ForEach( x =>
                               {
                                   if( x.Name.Contains( "o" ) )
                                       x.IsSelected = true;
                               } );
    
            MyGrid.DataContext = People;
        }
    }
    
    public class Person
    {
        public string Name { get; set; }
        public bool IsSelected { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have the following code: abstract class Animal case class Dog(name:String) extends
Lets say I have a single object of type Car which I want to
Let's say I have a table tbl with columns id and title . I
Let's say I have a database column 'grade' like this: |grade| | 1| |
Lets say I have a Dictionary object: Dictionary myDictionary<int, SomeObject> = new Dictionary<string, SomeObject>();
Lets say I have several web sites on my web server, all as applications
Lets say I have an array like this: string [] Filelist = ... I
Lets say we have something like: <div class=row> <div class=box> <a class=more href=#more/> </div>
Lets say I have a table in a sql server 2000 database called TransactionType:
Lets say I have two tables - child and parent with many-to-one relation. What

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.