Skip to content

[HELP] How to specify a fixed size for the application window? (.NET MAUI Blazor WinUI) #2370

Answered by jwiggenhorn
jwiggenhorn asked this question in Q&A
Discussion options

You must be logged in to vote

For anyone else having this issue, here's what ended up working for me:

// App.xaml.cs

	public App()
	{
		InitializeComponent();

                Microsoft.Maui.Handlers.WindowHandler.WindowMapper[nameof(IWindow)] = (handler, view) =>
                {
#if WINDOWS
                	var nativeWindow = handler.NativeView;
            		nativeWindow.Activate();
            		IntPtr windowHandle = PInvoke.User32.GetActiveWindow();

            		PInvoke.User32.SetWindowPos(windowHandle, 
					PInvoke.User32.SpecialWindowHandles.HWND_TOP,
                                        0, 0, width, height,  // width and height are ints
                                        PInvoke.User32.SetWindowPo…

Replies: 7 comments 36 replies

Comment options

You must be logged in to vote
5 replies
@Crauzer
Comment options

@jwiggenhorn
Comment options

@PaulChek
Comment options

@kla50
Comment options

@Xyncgas
Comment options

Answer selected by jwiggenhorn
Comment options

You must be logged in to vote
10 replies
@ItsOswin
Comment options

@LanceMcCarthy
Comment options

@ToolmakerSteve
Comment options

@sellorio2
Comment options

@sabre230
Comment options

Comment options

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

@kla50
Comment options

Comment options

You must be logged in to vote
7 replies
@Ewerton
Comment options

@billn6
Comment options

@billn6
Comment options

@gfmoore
Comment options

@asmtzl
Comment options

Comment options

You must be logged in to vote
12 replies
@LanceMcCarthy
Comment options

@phollyer
Comment options

@phollyer
Comment options

@LanceMcCarthy
Comment options

@phollyer
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet