Apply Storyboard Animation to DataGridTemplateColumn depending on Binding value change

Posted by Neo on Stack Overflow See other posts from Stack Overflow or by Neo
Published on 2010-05-25T01:17:52Z Indexed on 2010/05/25 1:21 UTC
Read the original article Hit count: 348

I have a DataGridTemplateColumn on a WPF DataGrid which has a binding to a double type. I wish to apply a Storyboard Animation when the value goes down and another Storyboard Animation when the value goes up. I've got the following code to start with:

<dg:DataGridTemplateColumn Header="My Double">
    <dg:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Path=MyDouble, NotifyOnTargetUpdated=True}" TargetUpdated="dgRates_TargetUpdated">
                <TextBlock.Triggers>
                    <EventTrigger RoutedEvent="Binding.TargetUpdated">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:2" From="1.0" To="0.0" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </TextBlock.Triggers>
            </TextBlock>
        </DataTemplate>
    </dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>

How can I achieve this? Thanks.

© Stack Overflow or respective owner

Related posts about animation

Related posts about storyboard