sous2817
Member
- Joined
- Apr 5, 2011
- Messages
- 17
- Programming Experience
- Beginner
Hello everyone,
Fairly new to vb.net, and even newer to animating an object. What I'm trying to do is adjust the height, width, and opacity all in one go. I've done it like this:
Surely there's a better way to do it than repeating the same steps over and over. If anyone has the time, I'd greatly appreciate any help you can provide.
Thanks in advance!
Fairly new to vb.net, and even newer to animating an object. What I'm trying to do is adjust the height, width, and opacity all in one go. I've done it like this:
VB.NET:
Sub AnimationTest()
Dim myDoubleAnimation As DoubleAnimation = New DoubleAnimation()
' Height
myDoubleAnimation.From = 2
myDoubleAnimation.To = StackPanel1.Height
myDoubleAnimation.Duration = New Duration(TimeSpan.FromSeconds(1))
myStoryboard = New Storyboard()
myStoryboard.Children.Add(myDoubleAnimation)
Storyboard.SetTargetName(myDoubleAnimation, Viewbox1.Name)
Storyboard.SetTargetProperty(myDoubleAnimation, New PropertyPath(Viewbox.HeightProperty))
myStoryboard.Begin(Me)
' Width
myDoubleAnimation.From = 2
myDoubleAnimation.To = StackPanel1.Width
myDoubleAnimation.Duration = New Duration(TimeSpan.FromSeconds(1))
myStoryboard = New Storyboard()
myStoryboard.Children.Add(myDoubleAnimation)
Storyboard.SetTargetName(myDoubleAnimation, Viewbox1.Name)
Storyboard.SetTargetProperty(myDoubleAnimation, New PropertyPath(Viewbox.WidthProperty))
myStoryboard.Begin(Me)
'Opacity
myDoubleAnimation.From = 0
myDoubleAnimation.To = 1
myDoubleAnimation.Duration = New Duration(TimeSpan.FromSeconds(1))
myStoryboard = New Storyboard()
myStoryboard.Children.Add(myDoubleAnimation)
Storyboard.SetTargetName(myDoubleAnimation, Viewbox1.Name)
Storyboard.SetTargetProperty(myDoubleAnimation, New PropertyPath(Viewbox.OpacityProperty))
myStoryboard.Begin(Me)
End Sub
Surely there's a better way to do it than repeating the same steps over and over. If anyone has the time, I'd greatly appreciate any help you can provide.
Thanks in advance!