0

我像这样调整停靠面板的大小:

Private WithEvents PanelAnimation As New DoubleAnimation
Private WithEvents PanelSB As New Storyboard

With PanelAnimation
        .From = WpfDockPanel.ActualHeight
        .To = s
        .Duration = New Duration(TimeSpan.FromSeconds(0.5))
        .AccelerationRatio = 0.5
        .DecelerationRatio = 0.5
End With
PanelSB.Children.Add(PanelAnimation)
Storyboard.SetTarget(PanelAnimation, WpfDockPanel)
Storyboard.SetTargetProperty(PanelAnimation, New PropertyPath(DockPanel.HeightProperty))
PanelSB.Begin(AviMainWindow)

..效果很好。然后,我想手动设置大小,但它不会改变,如果我停止代码并输入不同的大小,大小不会改变,就好像它是只读的一样。

但是如果我改变一次大小,而不是通过动画,只是通过设置大小,我可以再次改变它没有问题。为什么我不能在动画后手动设置高度?

谢谢

4

2 回答 2

2

这是因为动画的FillBehavior默认设置为HoldEnd。您可以将其设置为Stop.

但是,您还必须Height在开始动画之前手动将动画目标的属性设置为所需的结束值。否则它将翻转回动画开始之前的值。

With PanelAnimation
        .FillBehavior = FillBehavior.Stop
        ...

...
WpfDockPanel.Height = s
PanelSB.Begin(AviMainWindow)
于 2012-10-23T09:51:52.247 回答
0

可能您需要删除动画应用的值。就像是

WpfDockPanel.BeginAnimation(DockPanel.HeightProperty, null)

应该做的伎俩。

于 2012-10-23T09:54:03.593 回答