gpt4 book ai didi

wpf - 从右到左动画宽度

转载 作者:行者123 更新时间:2023-12-05 03:15:10 26 4
gpt4 key购买 nike

我想为从屏幕右边缘进入的窗口制作动画。

这是我的xaml

<Window x:Class="SidebarTest.DockWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="DockWindow" Width="275"
ShowInTaskbar="False"
WindowStyle="None" ResizeMode="NoResize"
AllowsTransparency="True" Background="Transparent" >

<Window.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard >
<DoubleAnimation Duration="0:0:1.5" Storyboard.TargetProperty="Width" From="0" To="275" AccelerationRatio=".1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Window.Triggers>

<Grid Background="#2F2F2F">

</Grid>

但它是从左到右而不是从右到左设置宽度动画。像这样:

enter image description here enter image description here

我如何更改它以使其从边缘进入?

最佳答案

在你的代码隐藏中,

public DockWindow()
{
InitializeComponent();
this.Left = this.Width + SystemParameters.FullPrimaryScreenWidth;
}

将触发器更改为

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

关于wpf - 从右到左动画宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20286192/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com