怎么才能触发 storyboard.Complete 事件?
界面上有个按钮 button1 和内容标签 label1。我想在点击 button1 以后,让 label1 消失。动画执行完毕后,再执行别的东西。代码如下:
private void button1_Click(object sender, RoutedEventArgs e){ Storyboard story = new Storyboard(); DoubleAnimation d = new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(1000)); story.Children.Add(d); this.RegisterName("label1", label1); Storyboard.SetTargetProperty(d, new PropertyPath(FrameworkElement.OpacityProperty)); Storyboard.SetTargetName(d, "label1"); story.Begin(this, true); story.Completed += new EventHandler(d_Completed);}void d_Completed(object sender, EventArgs e){ MessageBox.Show("事情做完了!");}