[英]Storyboard DoubleAnimation Does not work with StackPanel Height Property
[英]How to assign the height property of the parent container to the to parameter of DoubleAnimation in xaml?
如标题所述,我想知道如何将容器的高度(或ActualHeight
)分配给xaml中DoubleAnimation
的To
参数/属性?
这是我的代码:
<Canvas Name="animCanvas">
<Rectangle
Name="animSquare"
Canvas.Left="0"
Fill="AliceBlue"
Stroke="Bisque"
StrokeThickness="5"
Width="100"
Height="100"
>
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<DoubleAnimation
Storyboard.TargetName="animSquare"
Storyboard.TargetProperty="(Canvas.Top)"
From="0"
To="500" <!-- I want to set it to the containers height -->
Duration="0:0:1"
/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>
</Canvas>
您可以像这样将Binding应用于双重动画的To
属性:
To="{Binding ElementName=animSquare, Path=Height}"
我认为这可以解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.