本文介绍了动画窗口调整大小(宽度和高度)C#WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在寻找一些帮助动画上一个开放的窗口的窗口大小调整!
似乎无法弄清楚这一个!
I'm looking for some help on animating window resize of an open window!Cant seem to figure this one out!
我只是用ATM。
this.Width = 500;
任何帮助将是巨大的!
谢谢你。
Any help would be great!Thanks.
推荐答案
我已经回答了这个问题我自己。下面是一些示例code。
I have answered this question myself. Here is some sample code.
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蜱将最终调整大小以确切大小,把它擦亮了。
Resizes the window in 12 "ticks" very quickly, can be slowed down in _Timer.Interval. After 12 ticks will polish it off with a final resize to exact size.
希望这有助于someome。
Hope this helps someome.
这篇关于动画窗口调整大小(宽度和高度)C#WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!