How do I restore the initial value in the DataTrigger ExitActions after the animation ends?

I am very frustrated that it should be relatively straight forward. I have an alarm clock, whenever the state changes, I want to animate the scale of the text to increase its size. This should repeat 3 times and then stop leaving the text with its original meaning.

I went through every example I could find and tried several different implementations with no effect. After the animation stops, the text remains large. Why is nothing working in my DataTrigger? Does ExitActions work by shooting?

<TextBlock Grid.Column="1" Grid.Row="0" FontSize="22" Text="{Binding Path=DisplayName, IsAsync=True}" Padding="2,0,2,0">
    <TextBlock.RenderTransform> 
        <ScaleTransform x:Name="scale" /> 
    </TextBlock.RenderTransform>
<TextBlock.Style>
    <Style TargetType="{x:Type TextBlock}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Value, Converter={StaticResource AlarmConverter}, IsAsync=True}" Value="true">
                <DataTrigger.EnterActions>
                    <RemoveStoryboard BeginStoryboardName="NewAlarm" />                                                     
                        <BeginStoryboard Name="NewAlarm">
                            <Storyboard RepeatBehavior="3x" >
                                <DoubleAnimation  Storyboard.TargetProperty="RenderTransform.ScaleX"
                                                  Duration="00:00:02" 
                                                  From="1"
                                                  To="1.5"  />

                                 <DoubleAnimation  
                                                   Storyboard.TargetProperty="RenderTransform.ScaleY"
                                                   Duration="00:00:02"
                                                   From="1" To="1.5"  />
                            </Storyboard>
                        </BeginStoryboard>
                    </DataTrigger.EnterActions>
                    <DataTrigger.ExitActions>
                        <RemoveStoryboard  BeginStoryboardName="NewAlarm" />
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation  
                                  Storyboard.TargetProperty="RenderTransform.ScaleX"
                                    Duration="00:00:01" />

                                     <DoubleAnimation  
                                  Storyboard.TargetProperty="RenderTransform.ScaleY"
                                  Duration="00:00:01" />
                                </Storyboard>
                             </BeginStoryboard>
                          </DataTrigger.ExitActions>
                       </DataTrigger>
                    </Style.Triggers>
                </Style>
           </TextBlock.Style>
       </TextBlock>

      

  • I've tried using Autoreverse, but I really don't like the way the animation looks.
  • I've tried with and without a tag in ExitActions.
  • I've tried the From and To settings in the ExitAction animation.
  • I am trying to set just now in ExitAction 5 animation I tried to set only Duration and no To in ExitAction 6 animation I tried with and without tag in EnterActions
  • I tried to add a third animation which started after the first two ended, which
+3


source to share


1 answer


Called exitActions when the value returned from the converter is false, but you want to remove the animation as soon as you're done with it.

This can be done by setting the FillBehavior to on your storyboard means that you don't want the animation to retain its value after it has reached the end of its active period. Stop



<Storyboard FillBehavior="Stop" RepeatBehavior="3x" >
    <DoubleAnimation  
        Storyboard.TargetProperty="RenderTransform.ScaleX"
        Duration="00:00:02" 
        From="1"
        To="1.5"  />
    <DoubleAnimation  
        Storyboard.TargetProperty="RenderTransform.ScaleY"
        Duration="00:00:02"
        From="1" To="1.5"  />
</Storyboard>

      

With this, you can get rid of ExitActions if not required.

+1


source







All Articles