I've tried all of these answers, none of them worked:
https://stackoverflow.com/a/44273903/2901207 -> Simply doesn't do anything, tried to put it in different places but mostly just as the answer does. No response. This code:
private void MaximizeWindowOnLoad() { var view = DisplayInformation.GetForCurrentView(); // Get the screen resolution (APIs available from 14393 onward). var resolution = new Size(view.ScreenWidthInRawPixels, view.ScreenHeightInRawPixels); // Calculate the screen size in effective pixels. // Note the height of the Windows Taskbar is ignored here since the app will only be given the maxium available size. var scale = view.ResolutionScale == ResolutionScale.Invalid ? 1 : view.RawPixelsPerViewPixel; var bounds = new Size(resolution.Width / scale, resolution.Height / scale); ApplicationView.GetForCurrentView().SetPreferredMinSize(bounds); ApplicationView.PreferredLaunchViewSize = new Size(bounds.Width, bounds.Height); ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize; }
I've tried to execute before and after
this.InitializeComponent();
of the main page. I've tried to do it in theApp
constructor but that throws an exception forDisplayInformation.GetForCurrentView();
. I have tried to do it just after the Frame is created but no luck as well.https://stackoverflow.com/a/35250107/2901207 -> Does resize but not maximized, because the window is not in the top-left corner it does not work to remove the
-100
. Also setting to a very large value returnsfalse
forTryResizeView
.And of course I have tried to use:
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Maximized;
How do I get my UWP app the be maximized but not full screen. I just want to press that maximize button via code! So easy, yet so difficult.