0

I have a simple window where the user scans a barcode and you get an animation based on the barcode.

after the first animation it stops receiving the Window_KeyDown event.

The animation is triggered via code because it needs to read the barcode.

This is the storyboard.

    <Storyboard x:Key="Win">
        <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" Storyboard.TargetName="txtbScan">
            <DiscreteStringKeyFrame KeyTime="0:0:05" Value="Scan your barcode"/>
        </StringAnimationUsingKeyFrames>
    </Storyboard>

Here i call in code.

                Dim win As Storyboard = DirectCast(FindResource("Win"), Storyboard)
                txtbScan.Text = "Hurray you won " & GetPrize(curBarcode)
                win.Begin(Me)

It looks like the animation continues and cannot receive the next input event.

Wonko the Sane
  • 10,623
  • 8
  • 67
  • 92
monsey11
  • 243
  • 4
  • 18
  • possible duplicate of [How to stop an animation in C# / WPF?](http://stackoverflow.com/questions/20298/how-to-stop-an-animation-in-c-sharp-wpf) – Emond May 30 '13 at 19:59

1 Answers1

0

Yeah, that's a weirdness with WPF. Animations don't clear until you call a null animation on the animated property. Try this:

// You have to run a 'null' animation to clear an animated property
win.BeginAnimation(TextBlock.TextProperty, null)

something to that effect. (Not sure how to properly format VB).

Edit:

Take a look at this How to stop an animation in C# / WPF?

Community
  • 1
  • 1
sircodesalot
  • 11,231
  • 8
  • 50
  • 83
  • 1
    Or just set the animation's [FillBehavior](http://msdn.microsoft.com/en-us/library/system.windows.media.animation.timeline.fillbehavior.aspx) property to `Stop`. – Clemens May 30 '13 at 21:15