1. 程式人生 > >WPF中如何獲得等比列縮放的視窗

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