WPF中如何获得等比列缩放的窗口

 

double ScreenWidth;  //满屏窗口宽度
double ScreenHeight; //满屏窗口高度
double WindowWidth;  //WPF窗口宽度
double WindowHeight; //WPF窗口高度

ScreenWidth 
= SystemParameters.PrimaryScreenWidth;

ScreenHeight 
= SystemParameters.PrimaryScreenHeight;

WindowWidth 
= ScreenWidth/1.5;//这里也可以设置你想要的任何值,如:800
WindowHeight = ScreenHeight*WindowWidth/ScreenWidth;//这个就是根据屏幕的比例自动获得高度

this.width = WindowWidth;
this.height = WindowHeight;
posted @ 2011-09-14 15:52  海底的鱼  阅读(2463)  评论(0)    收藏  举报