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!