如何最大化 UWP 窗口(非全屏)

编程入门 行业动态 更新时间:2024-10-24 10:25:55
本文介绍了如何最大化 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.

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

祝你好运!

更多推荐

如何最大化 UWP 窗口(非全屏)

本文发布于:2023-07-11 12:21:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1094044.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:全屏   窗口   UWP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!