C# 如何在WPF中从右到左显示具有滑动效果的窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15898961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to show a window with sliding effect from right to left in WPF
提问by Raj
I want to show all my windows except Main page from right to left transition style.
我想从右到左的过渡样式显示除主页之外的所有窗口。
I tried this
我试过这个
<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>
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.
就像我需要显示窗口本身一样明智。
How to achieve this ?
如何实现这一目标?
采纳答案by sa_ddam213
A DoubleAnimation
on the Left
property should do the trick
A DoubleAnimation
on the Left
property 应该可以解决问题
<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>