根据屏幕分辨率自动调整Windows应用程序的屏幕大小

时间:2019-04-19 04:58:12

标签: wpf xamarin.wpf

我目前正在制作一个包含1个窗口和许多相似格式页面(宽度= 800,高度= 450)的应用程序。

如果我未定义minwidth和minheight,则屏幕如下图所示(下图),如果我定义了minwidth和minheight(1000,650),则该屏幕不适用于所有屏幕分辨率(在小型笔记本电脑中)屏幕正在切割)。

enter image description here

如何使窗口适合屏幕分辨率,且宽度和高度的最小值应为屏幕分辨率的(70%,70%)。

我尝试使用 this.sizetocontent = SizeToContent.WidthAndHeight ,但没有用。有人可以帮我吗?

谢谢:)

1 个答案:

答案 0 :(得分:0)

设置屏幕尺寸

Width =System.Windows.SystemParameters.PrimaryScreenWidth;
Height = System.Windows.SystemParameters.PrimaryScreenHeight;

将最小尺寸设置为70%

MinWidth=70* width / 100 ;
MinHeight=70* height / 100 ;