Changing FillBehaviour at animation end.

I'd like to modify the value of a property that's controlled by an animation using FillBehaviour=HoldEnd after animation has ended.
Tried changing Fillbehaviour by code and also stopping animation with no luck.

Any idea




Answer this question

Changing FillBehaviour at animation end.

  • cereyan

    So you want the holdEndAnimationRectangle's Width to go from 10 to 400 (over 1.5 seconds), and then snap back to 250 You could do that by adding a third animation that starts when the animation to 400 has completed, and goes instantly to 250:

    <Storyboard x:Key="sb1" Completed="OnCompleted">
    <
    DoubleAnimation Storyboard.TargetName="deactiveAnimationRectangle" Storyboard.TargetProperty="Width" From="20" To="400" Duration="0:0:5" />
    <
    DoubleAnimation Storyboard.TargetName="holdEndAnimationRectangle" Storyboard.TargetProperty="Width" From="10" To="400" Duration="0:0:1.5" BeginTime="0:0:0.5"/>
    <
    DoubleAnimation Storyboard.TargetName="holdEndAnimationRectangle" Storyboard.TargetProperty="Width" To="250" Duration="0" BeginTime="0:0:2"/>
    </
    Storyboard>


  • DMan1

    Valentin,
    What I'd like to is, using this animation:

    <Window.Resources>
      <
    Storyboard x:Key="sb1" Completed="OnCompleted"
    >
         <
    DoubleAnimation  Storyboard.TargetName="deactiveAnimationRectangle" Storyboard.TargetProperty="Width" From="20" To="400" Duration="0:0:5"
    />
         <
    DoubleAnimation Storyboard.TargetName="holdEndAnimationRectangle" Storyboard.TargetProperty="Width" From="10" To="400" Duration="0:0:1.5" BeginTime="0:0:0.5"
    />
    </
    Storyboard
    >
    </
    Window.Resources
    >

    Being able, when animation ended, to set rectangle Width using: holdEndAnimationRectangle.Width = 250;

    Also tried:

    void OnCompleted (object sender, EventArgs e)
    {
      Storyboard sb = (Storyboard)this.FindResource("sb1"
    );
      sb.FillBehavior = FillBehavior
    .Stop;
      holdEndAnimationRectangle.Width = 250;
    }

     But no luck...


     



  • Daniel Deptford

    I don't think it's going to work after the animation was started. The only solution is to set FillBehaviour=Stop in the animation declaration. This will make the animated property to go back to the initial value once the animation has ended. If you don't want this behaviour, you will have to manually set the animated property to the end value in the animation's Completed event.


  • Changing FillBehaviour at animation end.