The most elegant way for Windows desktop apps (.NET 9), to set the initial app size and position (1/3-2/3) based on the users screen size, goes like this. Be sure to edit the App.xaml.cs in the base map, not the file in the platforms maps. Edit the code there like this:
protected override Window CreateWindow(IActivationState? activationState)
{
// App start-window size derived from screen properties
double screenWidth = DeviceDisplay.MainDisplayInfo.Width; // the user screen
double screenHeight = DeviceDisplay.MainDisplayInfo.Height;
double appWidth = screenWidth / 2.35d; // the app screen
double appHeight = screenHeight / 2.35d;
return new Window(new AppShell())
{
Width = appWidth,
Height = appHeight,
X = (screenWidth - appWidth) / 2.0d, // center horizontal
Y = (screenHeight - appHeight) / 3.0d, // 1/3 vertical
};
}
Do not forget to comment out the existing CreateWindow(...).