小编Mat*_*hew的帖子

无法在WPF中设置动画后设置属性

我用这段代码动画我的窗口:

winLogin login = new winLogin();
login.Owner = this;
login.Show();

DoubleAnimation da = new DoubleAnimation();
da.From = 0;
da.To = this.Left + ((this.Width - login.Width) / 2);
da.AutoReverse = false;
da.Duration = new Duration(TimeSpan.FromSeconds(0.1));
login.BeginAnimation(Window.LeftProperty, da);
Run Code Online (Sandbox Code Playgroud)

问题是,无论何时我设置Left此窗口的属性(在动画之后),它都会变得疯狂.

我使用此代码将子窗口始终放在中心,但Left我使用动画的窗口的属性无法正确更改.

private void Window_LocationChanged(object sender, EventArgs e)
{
        foreach (Window win in this.OwnedWindows)
        {
            win.Top = this.Top + ((this.Height - win.Height) / 2);
            win.Left = this.Left + ((this.Width - win.Width) / 2); 
        }
}
Run Code Online (Sandbox Code Playgroud)

wpf animation

3
推荐指数
1
解决办法
1468
查看次数

标签 统计

animation ×1

wpf ×1