如何最大化 UWP 窗口(非全屏) [英] How to maximize a UWP window (not fullscreen)

查看:44
本文介绍了如何最大化 UWP 窗口(非全屏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 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.

这是在 http://aka.ms/template10 (https://github.com/Windows-XAML/Template10/blob/master/Template10%20(Library)/Utils/MonitorUtils.cs#L58)

祝你好运!

这篇关于如何最大化 UWP 窗口(非全屏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆