Andrew Stephens
Andrew Stephens

Reputation: 10193

DoubleAnimation with "instant" change not smooth transition

I'm using the following animation to "flash" a control:

<DoubleAnimation Storyboard.TargetProperty="Opacity"
    From="1"
    To="0.3"
    AutoReverse="True"
    Duration="0:0:0.5"
    RepeatBehavior="Forever" />

The resulting effect is more like a fade in and out. What I'm really after is to just "flip" the opacity from one value to the other (and back) every 0.5 seconds, rather than a smooth transition. How do I achieve that?

Upvotes: 1

Views: 572

Answers (1)

Lupu Silviu
Lupu Silviu

Reputation: 1165

This is the solution you are looking for:

<Storyboard RepeatBehavior="Forever" Duration="0:0:0.5" AutoReverse="True">
       <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
              <DiscreteDoubleKeyFrame Value="0.3" KeyTime="0:0:0.25" />
       </DoubleAnimationUsingKeyFrames>
</Storyboard>

You can adapt it to your needs.

Upvotes: 2

Related Questions