如何在WPF中显示从右到左的滑动效果窗口

时间:2013-04-09 10:01:06

标签: c# wpf xaml

我希望从右到左过渡样式显示除主页面以外的所有窗口。

我试过这个

<Window.Triggers>
    <EventTrigger RoutedEvent="Window.Loaded">
        <BeginStoryboard>
            <!--<Storyboard>
                <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:2" FillBehavior="HoldEnd" />
            </Storyboard>-->

            <Storyboard >
                <ThicknessAnimation Duration="0:0:.8" Storyboard.TargetProperty="Margin" To="-1200,0,-100,0" AccelerationRatio=".1"/>
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
</Window.Triggers>

同样如果我把stackpanel触发它在窗口内从左到右来。

同样明智的我需要展示窗户本身。

如何实现这一目标?

1 个答案:

答案 0 :(得分:11)

DoubleAnimation属性上的Left应该可以解决问题

<Window.Triggers>
    <EventTrigger RoutedEvent="Window.Loaded">
        <BeginStoryboard>
            <Storyboard >
                <DoubleAnimation Duration="0:0:.8" Storyboard.TargetProperty="Left" From="1920" To="0" AccelerationRatio=".1"/>
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
</Window.Triggers>