CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Nov 2007

    Flashing DataGrid Cell - How to do it properly


    I am developing an application that requires showing data in a datagrid and having a "flashing" animation when the value of a cell changes.

    My (business object) class implements the INotifyPropertyChanged interface. I have a list of that class (via ListCollectionView)

    I've figured out a way to do it using DataGridTemplateColumn and a DataTemplate:

    In Window.Resources:
    <DataTemplate x:Key="FlashingCellMyProperty">
    <TextBlock Name="TextBlockValue" Text="{Binding lMyProperty, Mode=OneWay,NotifyOnTargetUpdated=True}">
    <SolidColorBrush x:Name="bgBrush" />
    <EventTrigger SourceName="TextBlockValue" RoutedEvent="Binding.TargetUpdated">
    <BeginStoryboard HandoffBehavior="Compose">
    <ColorAnimation Duration="0:0:0.03" Storyboard.TargetName="bgBrush" Storyboard.TargetProperty="Color" To="Red" AutoReverse="True"/>

    Then later in my window I have a grid that contains the DataGrid:
    <DataGrid AutoGenerateColumns="False" Name="dataGrid1" ItemsSource="{Binding MyList}">
    <DataGridTextColumn Header="Strike" Binding="{Binding ExpirationPrice}"/>
    <DataGridTemplateColumn Header="My Property" CellTemplate="{StaticResource FlashingCellMyProperty}"/>

    This works fine but it seem to me a little wasteful to have a data template for each property. Optimally I'd like to have a way to define a "style" or a control template or somehow change existing "stock" column (e.g. DataGridTextColumn) and only change the binding on each column.

    I've search a lot online but didn't find the right path to follow. I am new to WPF and trying to read but there's much to read and I am not sure what subject I need to learn.

    Last edited by tomercagan; August 22nd, 2011 at 06:28 AM. Reason: Mistake in ItemSource used

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)