且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

[UWP]应用程序窗口大小正在重置(仅在一台PC上)

更新时间:2023-02-27 08:34:16

您是否使用调试器"STOP"来终止它?按钮?如果是这样,它将不记得大小。尝试在没有调试器的情况下运行它,根据需要调整大小,关闭它。




My UWP app is always launching at the same window size rather than remembering the size it was at previously. This happens on my main dev PC, but I can't reproduce it on my other PC, where the app does remember the size its window was the last time it was closed.

  • All other UWP apps (including apps I've built) are remembering their window size as expected. I have tested several.
  • My app remembers its window size on my laptop (from the exact same code, of course)
  • I have uninstalled the application and tried deploying it in Release and Debug modes with no change in behavior
  • There is no code running that checks or modifies the window size in any way
  • Since other apps deployed from VS work as expected I don't believe Visual Studio is the problem
  • Since apps installed from the store work as expected I don't believe there is a problem with Windows or the UWP platform
  • The app launches at the incorrect window size - it does not resize during the launch as it would if anything in my code was forcing the change.
  • I have compared the App.xaml.cs OnLaunched code, and it is doing the same stuff with the frame/content as my other apps that behave normally (and this app behaves as expected on another PC, so I can't imagine any possible issue there).
  • I tried running some earlier versions of the app and got the same problem - even though those earlier versions worked fine previously, so I think that rules out code.

My suspicion is that some remnant of my app is left on the system even after uninstalling. Is there a way to check for this?

-------Other details-----------

I have been updating my app to work on Xbox, and the screen size the app keeps remembering seems to be the size the app runs on Xbox (960x540). No Xbox-related code is running when I deploy to PC (I have verified this thoroughly, and have separate pages for all the Xbox content). My app has an Xbox build configuration, and in that, I do force the window to the Xbox size (to simulate Xbox while debugging), but I have thoroughly confirmed that code does not run unless the app is running on Xbox or with the Xbox build configuration. The app *launches* at the wrong window size, it doesn't change it after launch, which is what my Xbox build config does.

Any ideas?


Visit http://blog.grogansoft.com/ for Windows development fun.

Are you terminating it with the debugger "STOP" button? If so, it won't remember size. Try to run it without the debugger, size it however you want, close it.