10的Windows应用程序UWP - 在桌面上设置窗口大小 [英] Windows 10 UWP app - Setting window size on desktop

查看:210
本文介绍了10的Windows应用程序UWP - 在桌面上设置窗口大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Visual Studio 2015年社区版在Windows 10 Pro的学习UWP应用开发。我试图通过设置宽度修改官方的你好,世界样品的 C#版本在MainPage.xaml中的页面标签的高度属性。有趣的是,当我启动应用程序,它的大小也会有所不同。此外,如果我调整它的窗口,然后重新启动它,应用程序似乎在回忆以前的窗口大小。

I've just started learning UWP app development on Windows 10 Pro using Visual Studio 2015 Community Edition. I tried to modify the C# version of the official "Hello, world" sample by setting the Width and Height attributes of the Page tag in MainPage.xaml. Interestingly, when I start the app, its size will be different. Moreover, if I resize its window and then restart it, the app seems to remember its previous window size.

是否有可能迫使UWP应用程序有一个预定义的窗口大小,至少在台式机?

Is it possible to force a UWP app to have a predefined window size, at least on desktop PCs?

推荐答案

尝试设置 PreferredLaunchViewSize 中你的的MainPage 构造的这个样子。

Try setting PreferredLaunchViewSize in your MainPage's constructor like this.

public MainPage()
{
    this.InitializeComponent();

    ApplicationView.PreferredLaunchViewSize = new Size(480, 800);
    ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
}



更新

由于@kol也指出,如果你想要的大小比默认小的 500x320 的,您将需要手动重置。

As @kol also pointed out, if you want any size smaller than the default 500x320, you will need to manually reset it.

ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(200, 100));

这篇关于10的Windows应用程序UWP - 在桌面上设置窗口大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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