0

Running WPF in VB.NET...

How can I know whether my specific storyboard is finish running to its last frame?

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

After this storyboard is finish I will run this:

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

How to know my "shine_text" is finish so I can run the "text_come"?

*Edited Error

How to make it work:

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 Answer 1

1

Storyboard.Completed event is your answer. It occurs when this storyboard has completely finished playing.

C# sample

shine.Completed += StoryboardCompleted;

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

VB.Net Sample

AddHandler shine.Completed, AddressOf StoryboardCompleted

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

as alternative to code behind you can also specify the same from XAML

<Storyboard x:Name="shine" Completed="StoryboardCompleted">
5
  • That's great @Luiey, you may accept and upvote the answer to let others know that it works.
    – pushpraj
    Jun 3, 2014 at 2:24
  • my reputation is not enough to vote..sorry man. Got some problem when try to do completed on other page's storyboard as edited. Ever through this problem?
    – Luiey
    Jun 3, 2014 at 2:34
  • as per screens seems like you need to reference accordingly and problem should be solved. Also looks like these are generated file, so you may not focus here to change anything instead you adjust your original code for the accuracy.
    – pushpraj
    Jun 3, 2014 at 2:54
  • I just got it work..I'll put the solution I made to my post. No need to put Completed="Something_Completed" in XAML..just write this on behind code..
    – Luiey
    Jun 3, 2014 at 3:54
  • Great find. Now I got what you mean by error, you have to define in either code behind or in XAML, not both. that is the reason that I mentioned you can also specify the same from XAML I mean this is alternative approach for code behind. I'll update answer for clarification. Thanks :)
    – pushpraj
    Jun 3, 2014 at 4:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.