如何使用 C# 最大化 UWP 项目中的窗口(不是全屏!)?我尝试了以窗口边界为参数的 TryResizeView 方法,但没有任何反应.
How can I maximize a window in a UWP project (not fullscreen!) using C#? I tried the method TryResizeView with the window bounds as parameters but nothing happens.
谢谢
推荐答案这在 UWP 中目前是不可能的.所以,我不能让你最大化,但我可以让你非常接近:
This is not possible in UWP at this time. So, I can't get you Maximize, but I can get you pretty close:
var av = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView(); var di = Windows.Graphics.Display.DisplayInformation.GetForCurrentView(); var bounds = av.VisibleBounds; var factor = di.RawPixelsPerViewPixel; var size = new Windows.Foundation.Size(bounds.Width * factor, bounds.Height * factor); size.Height -= 100; size.Width -= 100; av.TryResizeView(size);基本上,减去 100(以允许 taskar).这在大多数情况下都有效,但如果没有真正的屏幕边界测量,我认为这是我们现在能做的最好的事情.对不起,我不能给你更多.任务栏的大小(和位置)是变量.
Basically, subtract 100 (to allow for the taskar). This will work in most cases, but without a true screen bounds measurement, I think this is the best we can do right now. Sorry I can't give you more. The TaskBar size (and location) is the variable.
这是在 aka.ms/template10 (github/Windows-XAML/Template10/blob/master/Template10%20(Library)/Utils/MonitorUtils.cs#L58)
祝你好运!
更多推荐
如何最大化 UWP 窗口(非全屏)
发布评论