可以在 WPF 中设置 HorizontalAlignment 动画吗?
我想为 Grid
中元素的水平(和垂直)对齐设置动画。我还希望动画是连续的(而不是离散的左、中、右值)。
<!-- starting state -->
<Grid>
<Button
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Content="Test"/>
</Button>
</Grid>
<!-- ending state -->
<Grid>
<Button
HorizontalAlignment="Right"
VerticalAlignment="Top"
Content="Test"/>
</Button>
</Grid>
我该如何实现这个目标?似乎没有任何动画类型支持这一点。显然这将是理想的:
<AlignmentAnimation From="Left" To="Right" />
想法?
I'd like to animate the horizontal (and vertical) alignment of an element within a Grid
. I'd also like the animation to be continuous (not discrete left, center, and right values).
<!-- starting state -->
<Grid>
<Button
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Content="Test"/>
</Button>
</Grid>
<!-- ending state -->
<Grid>
<Button
HorizontalAlignment="Right"
VerticalAlignment="Top"
Content="Test"/>
</Button>
</Grid>
How do I accomplish this? There doesn't seem to be any animation type that supports this. Obviously this would be ideal:
<AlignmentAnimation From="Left" To="Right" />
Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法为该属性设置动画,因为它只是一个
枚举
。动画需要中间值才能工作,例如双精度、点、颜色、厚度、尺寸等。You can't animate that property since it is just an
enum
. It would need intermediate values to have for the animation to work, like double, Point, Color, Thickness, Size, etc..