Skip to content

Set main window size for Windows desktop target #11173

Answered by Soap-141
wgraaf asked this question in Q&A
Discussion options

You must be logged in to vote

Make sure you only execute this on Windows.

	private void ConfigureViewSize()
	{
		var windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(CurrentWindow);
		var windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(windowHandle);
		var appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
		appWindow.Resize(new Windows.Graphics.SizeInt32 { Width = 480, Height = 800 });
	}

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@lucasmontec
Comment options

@MartinZikmund
Comment options

Answer selected by Soap-141
Comment options

You must be logged in to vote
3 replies
@Soap-141
Comment options

Soap-141 Sep 1, 2023
Collaborator

@wirelessfrank
Comment options

@Soap-141
Comment options

Soap-141 Sep 5, 2023
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants