1.示例
2.代码
<GridShowGridLines="True"><Grid.RowDefinitions><RowDefinitionHeight="*"/><RowDefinitionHeight="*"/></Grid.RowDefinitions><StackPanelHorizontalAlignment="Center"Orientation="Horizontal"><EllipseName="ellipse"Width="30"Height="30"Margin="0,0,0,5"HorizontalAlignment="Center"VerticalAlignment="Bottom"Fill="DarkBlue"><Ellipse.RenderTransform><ScaleTransform/></Ellipse.RenderTransform><Ellipse.Style><StyleTargetType="Ellipse"><Style.Triggers><DataTriggerBinding="{Binding ElementName=btnAnimate, Path=IsChecked}"Value="True"><DataTrigger.EnterActions><BeginStoryboard><Storyboard><ThicknessAnimationAutoReverse="True"Storyboard.TargetProperty="Margin"From="0,0,0,5 "To="0,0,0,50"Duration="0:0:0:0.3"/></Storyboard></BeginStoryboard></DataTrigger.EnterActions></DataTrigger></Style.Triggers></Style></Ellipse.Style></Ellipse></StackPanel><CheckBoxx:Name="btnAnimate"Grid.Row="1"Width="100"Height="50"HorizontalAlignment="Center"VerticalAlignment="Center"Content="Animate"/></Grid>
3.解释
此例使用Storyboard和ThicknessAnimation属性完成元素位置移动