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

  • Home
  • SEARCH
  • 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 6888969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:05:45+00:00 2026-05-27T06:05:45+00:00

I have a WPF DataGrid which is populated from a database. There is a

  • 0

I have a WPF DataGrid which is populated from a database. There is a cell which gives me a count. I want to add a flashing Background color to that cell if its value is more than 0. Thanks for helping me with my problem.

  • 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-27T06:05:46+00:00Added an answer on May 27, 2026 at 6:05 am

    Create a converter that will check to see if a cell contains a number greater than 0:

    namespace MyApp
    {
        public class GreaterThanZeroConverter : IValueConverter
        {
            public object Convert(object value, Type targetType,
                object parameter, CultureInfo culture)
            {
                int cellValue;
                return Int32.TryParse((string)value, out cellValue) && cellValue > 0;
            }
    
            public object ConvertBack(object value, Type targetType,
                object parameter, CultureInfo culture)
            {
                return false;
            }
        }
    }
    

    Include your converter namespace in the xaml. Replace MyApp with the namespace of your converter:

    xmlns:myApp="clr-namespace:MyApp"
    

    Your grid will have to look something like this. The objects I am binding to have 2 properties: Col1 and Col2. If the value of Col1 is greater than 0, that cell will flash red.

    <DataGrid ItemsSource="{Binding List}" AutoGenerateColumns="False">
        <DataGrid.Resources>
            <myApp:GreaterThanZeroConverter 
                x:Key="GreaterThanZeroConverter">
            </myApp:GreaterThanZeroConverter>
            <Style TargetType="DataGridCell" x:Key="FlashStyle">
                <Style.Triggers>
                    <DataTrigger 
                        Binding="{Binding Col1, 
                        Converter={StaticResource GreaterThanZeroConverter}}" 
                        Value="True" >
                        <DataTrigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard 
                                    x:Name="Blink" 
                                    AutoReverse="True" 
                                    RepeatBehavior="Forever">
                                    <ColorAnimationUsingKeyFrames 
                                        BeginTime="00:00:00"
                                        Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)">
                                        <EasingColorKeyFrame 
                                            KeyTime="00:00:01" 
                                            Value="Red" />
                                    </ColorAnimationUsingKeyFrames>
                                </Storyboard>
                            </BeginStoryboard>
                        </DataTrigger.EnterActions>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </DataGrid.Resources>
        <DataGrid.Columns>
            <DataGridTextColumn 
                Binding="{Binding Col1}" 
                CellStyle="{StaticResource FlashStyle}"></DataGridTextColumn>
            <DataGridTextColumn 
                Binding="{Binding Col2}"></DataGridTextColumn>
        </DataGrid.Columns>
    </DataGrid>
    

    Edit

    If you have to make cells in multiple columns blink based on what they contain, you can change

    <DataTrigger 
        Binding="{Binding Col1, 
        Converter={StaticResource GreaterThanZeroConverter}}" 
        Value="True" >
      ...
    

    To

    <DataTrigger 
        Binding="{Binding 
            Content.Text,
            RelativeSource={RelativeSource Self},
            Converter={StaticResource GreaterThanZeroConverter}}" 
        Value="True" >
    

    And set the CellStyle for each of the columns that you want to blink to our FlashStyle:

    <DataGrid.Columns>
        <DataGridTextColumn 
            Binding="{Binding Col1}" 
            CellStyle="{StaticResource FlashStyle}"></DataGridTextColumn>
        <DataGridTextColumn 
            Binding="{Binding Col2}"
            CellStyle="{StaticResource FlashStyle}"></DataGridTextColumn>
    </DataGrid.Columns>
    

    Note that this will probably only work with DataGridTextColumns. If you are using DataGridTemplateColumns it will be a bit more tricky.

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

Sidebar

Related Questions

I have a strange problem with a WPF DataGrid from WPF Toolkit. The scrollbars
I have a wpf datagrid which is bound to an observable collection. Currently I
I have a WPf Toolkit-datagrid..in my application which follows MVVM pattern. How I can
I have a WPF application which shows items in a DataGrid (XCeed DataGrid). The
I have a wpf window which is used to add as well as edit
Details VS-2008 Professional SP1 Version .net 3.5 Language:C# I have a WPF Datagrid which
I have a datagrid from wpf Toolkit, with the itemsource binded to a Observable<Item>
I have a DataGrid (WPF 4) like this: <DataGrid Margin=0,0,0,5 VerticalAlignment=Top Height=192 BorderBrush=#aaa Background=White
I want to design a DataGrid in which I have option to Group by
I have WPF DataGrid placed on the Window . I have a button which

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.