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>
效果如下:


posted @ 2017-01-13 21:08  高山百川  阅读(4241)  评论(0编辑  收藏  举报