none
代码控制StoryBoard的问题 RRS feed

  • 问题

  • 我有一个问题想请教下各位高手。

    我有一个button,我想当我按下去以后,执行一个StoryBoard,然后当这个StoryBoard执行结束后接着执行另外一个StoryBoard,这个怎么实现呢?

    我只能实现执行一个,但是不知道怎么监视他的状态,当他执行结束后执行另外一个。

                    Storyboard myStoryboard;
                    myStoryboard = (Storyboard)this.Resources["ABC"];
                    myStoryboard.Begin(this);

    .......下面不知道怎么写了,请高手赐教

    2010年6月8日 1:34

答案

  • 您好,

    您可以参考下面的代码:

        private void button1_Click(object sender, RoutedEventArgs e)
        {
          Storyboard myStoryboard;
          myStoryboard = (Storyboard)this.Resources["ABC"];
          myStoryboard.Completed += new EventHandler(myStoryboard_Completed);
          myStoryboard.Begin(this);
        }
    
        void myStoryboard_Completed(object sender, EventArgs e)
        {
          var nextStoryBoard = this.Resources["nextStoryBoard"] as Storyboard;
          nextStoryBoard.Begin(this);
        }

     

    Aland Li


    Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
    2010年6月11日 9:52
    版主

全部回复

  • Storyboard sb = new Storyboard();
    sb.Completed += new EventHandler(sb_Completed);

    Completed就是动画播放完成后的事件

    2010年6月9日 2:08
  • 谢谢你的答案哦,不过我还是不是很会用,能麻烦您把代码详细点吗?

    比如我要在动画ABC结束后播放DEF,应该怎么写呢

    2010年6月9日 9:36
  • 您好,

    您可以参考下面的代码:

        private void button1_Click(object sender, RoutedEventArgs e)
        {
          Storyboard myStoryboard;
          myStoryboard = (Storyboard)this.Resources["ABC"];
          myStoryboard.Completed += new EventHandler(myStoryboard_Completed);
          myStoryboard.Begin(this);
        }
    
        void myStoryboard_Completed(object sender, EventArgs e)
        {
          var nextStoryBoard = this.Resources["nextStoryBoard"] as Storyboard;
          nextStoryBoard.Begin(this);
        }

     

    Aland Li


    Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
    2010年6月11日 9:52
    版主