在WPF中最简单的动画按钮位置是什么? [英] What is the easiest to animate the position of button in wpf?
本文介绍了在WPF中最简单的动画按钮位置是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在单击画布时在其上移动按钮的方式是逐渐改变其位置(动画),而不是消失并重新出现在新位置。
I want to move a button across a canvas when it's clicked in a way that it changes its position gradually(animation), not vanishing and reappearing in the new position.
推荐答案
您可以使用 Storyboard
将其平滑移动:
You can use a Storyboard
that will move it smoothly:
<Grid>
<Canvas>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="50,250,0,0" Name="buttonAnimate" VerticalAlignment="Top" Width="75">
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation From="0" To="100" Duration="0:0:2" Storyboard.TargetProperty="(Canvas.Left)" AutoReverse="False" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
</Canvas>
</Grid>
这篇关于在WPF中最简单的动画按钮位置是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文