gpt4 book ai didi

c# - 动画窗口调整大小(宽度和高度)C# WPF

转载 作者:行者123 更新时间:2023-11-30 14:04:31 26 4
gpt4 key购买 nike

我正在寻找有关动画调整打开窗口大小的帮助!似乎无法弄清楚这一点!

我只是在使用 atm。

this.Width = 500;

任何帮助都会很棒!谢谢。

最佳答案

我自己回答了这个问题。这是一些示例代码。

    static System.Windows.Forms.Timer _Timer = new System.Windows.Forms.Timer(); 
int _Stop = 0;

private void This_Loaded(object sender, RoutedEventArgs e)
{
_Timer.Tick += new EventHandler(timer_Tick);
_Timer.Interval = (20);

resize(500,500)
}

private void timer_Tick(Object myObject, EventArgs myEventArgs)
{
if (_Stop == 0)
{
_RatioHeight = ((this.Height - _Height) / 12)* -1;
_RatioWidth = ((this.Width - _Width) / 12)* -1;
}
_Stop++;

this.Height += _RatioHeight;
this.Width += _RatioWidth;

if (_Stop == 12)
{
_Timer.Stop();
_Timer.Enabled = false;
_Timer.Dispose();

_Stop = 0;

this.Height = _Height;
this.Width = _Width;
}
}

public void resize(double _PassedHeight, double _PassedWidth)
{
_Height = _PassedHeight;
_Width = _PassedWidth;

_Timer.Enabled = true;
_Timer.Start();
}

以 12 个“刻度”非常快速地调整窗口大小,可以在 _Timer.Interval 中放慢速度。 12 个刻度后,将最终调整到精确大小,将其抛光。

希望这对某些人有帮助。

关于c# - 动画窗口调整大小(宽度和高度)C# WPF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1769317/

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