如何在WPF中从右到左显示具有滑动效果的窗口 [英] how to show a window with sliding effect from right to left in WPF

查看:48
本文介绍了如何在WPF中从右到左显示具有滑动效果的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示除主页之外的所有窗口从右到左的过渡样式.

I want to show all my windows except Main page from right to left transition style.

我试过了

<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 触发器放在窗口内,它是从左到右的.

The same if i put stackpanel trigger it's coming from left to right inside the window.

就像我需要显示窗口本身一样.

Like wise i need for showing window itself.

如何实现?

推荐答案

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

A DoubleAnimation on the Left property should do the trick

<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>

这篇关于如何在WPF中从右到左显示具有滑动效果的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆