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;

摘抄自:https://www.cnblogs.com/Caceolod/articles/2176325.html

posted @ 2018-12-17 16:03  蜗牛的礼物  阅读(846)  评论(0)    收藏  举报