开发者

How to stop Storyboard like pausing

I'm trying to assign d开发者_如何学Cynamically created storyboards to dynamically created Rectangles. Actually I'm changing their TranlationTransform attributes:

Storyboard s = new Storyboard();

DoubleAnimationUsingKeyFrames translationAnimation1 =
    new DoubleAnimationUsingKeyFrames();

translationAnimation1.KeyFrames.Add(
    new EasingDoubleKeyFrame(TranslationX,
        KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Seconds))));

Storyboard.SetTarget(translationAnimation1, Element);

Storyboard.SetTargetProperty(translationAnimation1,
    new PropertyPath("(UIElement.RenderTransform).
                      (TransformGroup.Children)[3].(TranslateTransform.X)"));

s.Children.Add(translationAnimation1);


DoubleAnimationUsingKeyFrames translationAnimation2 =
    new DoubleAnimationUsingKeyFrames();

translationAnimation2.KeyFrames.Add(new EasingDoubleKeyFrame(TranslationY,
    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Seconds))));

Storyboard.SetTarget(translationAnimation2, Element);

Storyboard.SetTargetProperty(translationAnimation2,
     new PropertyPath("(UIElement.RenderTransform).
                       (TransformGroup.Children)[3].(TranslateTransform.Y)"));

s.Children.Add(translationAnimation2);

And I want to stop it when I clicked on it:

s.Pause();
s = null;

Yes it pauses but it prevents me to change the TranslateTransform attributes and calling Stop() is not good. The question is how I can stop a storyboard when I clicked on it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜