tags:

views:

158

answers:

1

The following code makes the contents of a StackPanel fade in when it is loaded (StackPanel.Loaded).

What do I have to change to get the fade it to start when the contents of the StackPanel change, e.g. every time a message in the StackPanel changes I want it to fade in again?

<Style x:Key="MessageStyle" TargetType="StackPanel">
    <Style.Triggers>
        <DataTrigger Binding="{Binding SaveStatus}" Value="Failed">
            <Setter Property="StackPanel.Background" Value="Red"/>
        </DataTrigger>
        <EventTrigger RoutedEvent="StackPanel.Loaded">
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation
            Storyboard.TargetProperty="(StackPanel.Opacity)"
            From="0.0" To="1.0" Duration="0:0:5"/>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Style.Triggers>
</Style>
A: 

You should be able to do what you're looking for with the StackPanel.SourceUpdated/StackPanel.TargetUpdated event after setting the accompanying NotifyOnSourceUpdated/NotifyOnTargetUpdated property to True on the binding that binds the contents of the StackPanel.

Nicholas Armstrong