特定故事板完成后调用故事板

时间:2014-06-03 01:27:02

标签: wpf vb.net storyboard

在VB.NET中运行WPF ...

如何知道我的特定故事板是否已完成到最后一帧?

Dim shine As New Storyboard
shine = CType(Me.Resources("shine_text"), Storyboard)
shine.Begin(Me)

在这个故事板完成之后,我将运行:

Dim textcome As New Storyboard
textcome = CType(Me.Resources("text_come"), Storyboard)
textcome.Begin(Me)

如何知道我的“shine_text”已经完成,所以我可以运行“text_come”?

*被修改 Error

如何使其发挥作用:

Private Sub tb1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles tb1.MouseDown
      Dim mystoryboard As New Storyboard
      mystoryboard = CType(Me.Resources("click1"), Storyboard)
      AddHandler mystoryboard.Completed, AddressOf click_completed
      mystoryboard.Begin(Me)
End Sub

Private Sub click_completed(ByVal sender As Object, ByVal e As EventArgs)
     NavigateMe()
End Sub

1 个答案:

答案 0 :(得分:1)

Storyboard.Completed事件是你的答案。当故事板完全播放完毕时会发生这种情况。

C#样本

shine.Completed += StoryboardCompleted;

private void StoryboardCompleted(object sender, EventArgs e)
{
     //your logic on completion here
}

VB.Net示例

AddHandler shine.Completed, AddressOf StoryboardCompleted

Private Sub StoryboardCompleted(sender As Object, e As EventArgs)
    'your logic on completion here
End Sub

作为替代后面的代码,您也可以从XAML中指定相同的

<Storyboard x:Name="shine" Completed="StoryboardCompleted">