Ticket Q440731
Visible to All Users

Flash GridControl Cell on value changed?

created 12 years ago

I have a simple DXGrid control with an obervable collection as its ItemsSource. The Items implemenet INotifiyPropertyChanged and are updated every two seconds with new integer values.

I'm trying to make a cell of the DXGrid flash with a ColorAnimation when it's vallues is updated without hacking the code-behind (following the MVVM principle).

C#
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <Style TargetType="{x:Type dxg:CellContentPresenter}" x:Key="MyStyle"> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="Transparent"/> </Setter.Value> </Setter> <Style.Triggers> <EventTrigger RoutedEvent="Binding.TargetUpdated"> <BeginStoryboard HandoffBehavior="Compose"> <Storyboard> <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" Duration="00:00:01" AutoReverse="True" From="Transparent" To="Yellow" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Style.Triggers> </Style> </Window.Resources> <Grid> <Button Width="90" Height="30" Name="button1" Click="button1_Click" Margin="5" VerticalAlignment="Top"/> <dxg:GridControl Name="dataGrid1" ItemsSource="{Binding Values}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> <dxg:GridControl.Columns> <dxg:GridColumn Header="Value" DisplayMemberBinding="{Binding Value, Mode=OneWay, NotifyOnTargetUpdated=True}" CellStyle="{StaticResource MyStyle}"/> <dxg:GridColumn Header="Value 1" DisplayMemberBinding="{Binding Value1, NotifyOnTargetUpdated=True}" CellStyle="{StaticResource MyStyle}"/> </dxg:GridControl.Columns> </dxg:GridControl> </Grid> </Window>

If I changed the RoutedEvent to MouseEnter the animation is triggered so I think the OnTargetUpdate event is getting lost.

Is there a solution using this methodology?

Thanks!

Answers

created 12 years ago (modified 12 years ago)

Hi Matthew,
Thank you for your inquiry. The cause of this behavior is that we do not set the NotifyOnTargetUpdated property for cell bindings.
I am afraid there is no general way to implement this functionality. I suggest you review the following Code Central examples, which demonstrate how to animate the grid's content:
ID E1532, How to embed animation into grid cells
ID E841, How to highlight modified rows
ID Q323226, How to make every cell flashes when the displayed value changes
Please review them and let me know if you need further assistance.
Thanks

    Show previous comments (1)
    DevExpress Support Team 12 years ago

      Thank you for your update.
      In fact, even if we set the NotifyOnTargetUpdated property for cell bindings, this will not solve the issue. Let me explain why. Since DXGrid uses the virtualization mechanism, it re-uses cells when an end-user scrolls the grid. In other words, elements of visible rows are created only for visible rows, and each visual row is used for displaying different underlying rows. For this reason, the Binding.TargetUpdated event is raised even if the underlying cell value is not changed. I have attached a sample project demonstrating this behavior.
      I am afraid it is impossible to implement the required functionality by creating an event trigger for the Binding.TargetUpdated event. In this case, I advise you to use approaches demonstrated in the E1532, E841, and Q323226 examples.
      If you have additional questions, feel free to reactivate this thread.
      Thanks

        Hi,
        When i slide the scrollbar, cells are still flasing. Why? How can we correct it?
        Many Thanks,

        DevExpress Support Team 12 years ago

          It seems that you have posted a similar question in the following thread: "Q503078: Flash updated cell". Please refer to it for further discussion.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.