Reputation: 4270
Why does this animation result in the window moving across left to right in the original position first then jumping to the other position even though I set the width and height properties before the animation started. It seems to reset the height value when it starts to show the width and then changes it back when doing the second animation.
Sub ShowTitle(ByVal Text As String)
tb_text.Visibility = Windows.Visibility.Hidden
tb_text.Height = 5
tb_text.Width = 0
tb_text.Text = Text
tb_text.Visibility = Windows.Visibility.Visible
Dim SB As New Animation.Storyboard
Dim FIW = New Animation.DoubleAnimation(0, 400, New Duration(TimeSpan.FromSeconds(2)))
SB.Children.Add(FIW)
Animation.Storyboard.SetTargetName(FIW, tb_text.Name)
Animation.Storyboard.SetTargetProperty(FIW, New PropertyPath(WidthProperty))
Dim FIH = New Animation.DoubleAnimation(5.0, 50.0, New Duration(TimeSpan.FromSeconds(2)))
FIH.BeginTime = TimeSpan.FromSeconds(2)
SB.Children.Add(FIH)
Animation.Storyboard.SetTargetName(FIH, tb_text.Name)
Animation.Storyboard.SetTargetProperty(FIH, New PropertyPath(HeightProperty))
SB.Begin(Me)
End Sub
Upvotes: 0
Views: 399
Reputation: 4543
Not sure if this relates to your scenario, but I just spent 4 hours tracking down an animation of Width/Height (in my case of main window) bug. In all my desperate attempts at grasping for anything, I ended up stumbling over this post. In the end, for me "the fix" turned out to be switching the project back to use .NET Framework 3.5. If you have that luxury, try that and see if the behavior changes.
While both you and me have issues with animations and width/height, I found another person on MS connect who reported width/height not working property with triggers either (.NET framework 4.0 only). I built a very small test project that illustrates the issue and submitted my own bug report, but I'm not really holding my breath since the other guy posted his issue 20 months ago and his issue was "in triage and resolution" ever since.
Upvotes: 1