【问题标题】:how to show a window with sliding effect from right to left in WPF如何在WPF中显示具有从右到左滑动效果的窗口
【发布时间】:2013-04-09 10:01:06
【问题描述】:

我想显示我的所有窗口,除了主页从右到左的过渡样式。

我试过了

<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 触发器放在窗口内,它也是一样的。

同样,我需要显示窗口本身。

如何做到这一点?

【问题讨论】:

    标签: c# wpf xaml


    【解决方案1】:

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

    <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 的新手,无法完全理解。
    • 请参考这些过渡和动画的一些链接
    猜你喜欢
    • 1970-01-01
    • 2015-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多