wpf 如何让控件左右移动
通过DoubleAnimation可以让控件进行左右移动。
<Canvas x:Name="canvas_Shape" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="720" Margin="12,0" Grid.Column="1" Grid.RowSpan="7" > <Canvas.Triggers> <EventTrigger RoutedEvent="FrameworkElement.Loaded"> <BeginStoryboard > <Storyboard Storyboard.TargetName="bendediction" Storyboard.TargetProperty="(Canvas.Left)"> <DoubleAnimation From="0" To="400" Duration="0:0:10" RepeatBehavior="23:59:59" AutoReverse="True"/> </Storyboard> </BeginStoryboard> </EventTrigger> </Canvas.Triggers> <Button x:Name="bendediction" Style="{DynamicResource ButtonStyle}" Canvas.Top="200"/> </Canvas>
效果如下:
高山流水,海纳百川!