本文介绍了将按钮宽度设置为当前窗口大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在WPF中使用Visual Studio 08

我正在尝试对按钮进行动画处理以增大到当前窗口的大小,以便在调整屏幕大小并单击按钮时,它将增大到新的大小.

Using Visual Studio 08 with WPF

I''m trying to animate a button to grow to the current window size so that when the screen is resized and the button is clicked it will grow to the new size.

DoubleAnimation myDoubleAnimation = new DoubleAnimation();
myDoubleAnimation.From = 30;
int widthRange = Convert.ToInt32(Window1.ActualWidthProperty);
myDoubleAnimation.To = widthRange;
myDoubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(3000));
myDoubleAnimation.AutoReverse = true;



这样分配我的按钮就消失了
但是,如果我说:
myDoubleAnimation.To = 300;

效果很好

如何将这个Duration属性设置为主窗口的当前大小?



assigned this way my button dissapears
if however i say:
myDoubleAnimation.To = 300;

it works just fine

How can I set this Duration property to the current size of the main window?

推荐答案


这篇关于将按钮宽度设置为当前窗口大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 20:41