views:

181

answers:

2

So I'm attempting to move a ScatterViewItem from 1 point to the another. I've tried using PointAnimation. However, after the animation completes I can't move the item from the To point. I can spin the item and scale it, but for some reason can not move it.

It's a simple movement from 1 point to the next in a straight line. Should I be using PointAnimation or is there a better way? Thanks I'm doing this in C#

My point animation code:

        oPointAnimation = new PointAnimation();
        oPointAnimation.From = new Point(439, 113);
        oPointAnimation.To = new Point(139, 160);

        oPointAnimation.Duration = TimeSpan.FromSeconds(4);
        oPointAnimation.Completed += new EventHandler(oPointAnimation_Completed);
        theCard.BeginAnimation(ScatterViewItem.CenterProperty, oPointAnimation);
+1  A: 

I guess you need to use FillBehaviour of the POintAnimation to FillBehavior="Stop"

Jobi Joy
+1  A: 

Although you already have an accepted answer I'd like to add a point here.

Even with FillBehavior set to Stop, there are certain occasions where it just doesn't work. I believe it is in conjunction with HandoffBehavior set to SnapshotAndReplace. What I've done in those cases is to programmatically start a new animation (using BeginAnimation) on that dependency property with a null as second argument.

// Remove all animations for the Opacity property on the myElement element 
myElement.BeginAnimation(UIElement.OpacityProperty, null)

This effectively clears all animations for that dependency property and you can freely assign new values to it.

Isak Savo