嗨我有你的问题的解决方案,问题是你没有真正控制窗口大小,即使你会尝试重新调整它的大小,它可能会失败 . 我在msdn论坛上问了同样的问题并得到了答案
顺便说一下这里是您的事件处理程序“OnLaunched”或您的事件处理程序“OnActivated”中的解决方案:
Window.Current.Activate();
并替换为:
float DPI = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi;
Windows.UI.ViewManagement.ApplicationView.PreferredLaunchWindowingMode = Windows.UI.ViewManagement.ApplicationViewWindowingMode.PreferredLaunchViewSize;
var desiredSize = new Windows.Foundation.Size(((float)800 * 96.0f / DPI), ((float)600 * 96.0f / DPI));
Windows.UI.ViewManagement.ApplicationView.PreferredLaunchViewSize = desiredSize;
Window.Current.Activate();
bool result = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TryResizeView(desiredSize);
如果将此代码放入“OnActivated()”事件处理程序中会更好,因为它会在应用程序启动时以及在任何中断后变为活动时设置您定义的大小 .
在“desiredSize”中,计算800是宽度,600是高度需要此计算,因为大小是DPI,因此您必须将其从像素转换为DPI
另请注意,尺寸不能小于“320x200”