Click here to Skip to main content
15,746,107 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem with my code. The codes bellow are work well.. I can't animate more than 1 object in a time with these code. So i thought, i must add them to a storyboard, so i can animate more than 1 object in a time. how can i do that? sorry for my bad english..

Private Sub animation(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
       If anime_counter < counter Then
           Dim daX As New DoubleAnimation
           Dim daY As New DoubleAnimation

           If anime_counter = 0 Then
               daX.From = Pict1.Margin.Left
               daY.From = Pict1.Margin.Top
               daX.From = path(anime_counter - 1).X - Pict1.Margin.Left
               daY.From = path(anime_counter - 1).Y - Pict1.Margin.Top
           End If
           daX.To = path(anime_counter).X - Pict1.Margin.Left
           daY.To = path(anime_counter).Y - Pict1.Margin.Top

           Dim pixelsPerSecond As Double = 200
           Dim distance As Double = Math.Sqrt((daX.To - daX.From) * (daX.To - daX.From) + (daY.To - daY.From) * (daY.To - daY.From))
           daX.Duration = TimeSpan.FromSeconds(distance / pixelsPerSecond)
           daY.Duration = TimeSpan.FromSeconds(distance / pixelsPerSecond)
           AddHandler daX.Completed, AddressOf animation

           Dim tt As New TranslateTransform
           Pict1.RenderTransform = tt
           tt.BeginAnimation(TranslateTransform.XProperty, daX)
           tt.BeginAnimation(TranslateTransform.YProperty, daY)

           anime_counter += 1
           anime_counter = 0
       End If
   End Sub

Just create one storyboard for each animation.
Share this answer
how can i do that?? i can't add the story board programmatically.. :(
Share this answer
help me pls.. really need help... T__T
Share this answer
John is right. Just create the number of storyboards you need in your XAML. Each one will animate one property on one object.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900