15,041,525 members
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
Else
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)

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

anime_counter += 1
Else
anime_counter = 0
End If
End Sub
```
Posted

## Solution 4

John is right. Just create the number of storyboards you need in your XAML. Each one will animate one property on one object.

## Solution 3

help me pls.. really need help... T__T

## Solution 2

how can i do that?? i can't add the story board programmatically.. :(

## Solution 1

Just create one storyboard for each animation.

Top Experts
Last 24hrsThis month
 OriginalGriff 235 Richard Deeming 111 CPallini 90 Patrice T 80 merano99 80
 OriginalGriff 3,643 Richard MacCutchan 1,986 Richard Deeming 1,959 CPallini 1,278 Patrice T 864

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