Skip to content

How to disable window resize after the release of WinUI 3 1.0 Preview 3? #1694

Answered by martibravo
JohnCido asked this question in Q&A
Discussion options

You must be logged in to vote

This is quite easy to do with the new AppWindow APIs:

Add the following items to your MainWindow class:

using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml.Interop;
using System.Windows.Interop.WindowsRuntime;
private AppWindow _apw;
private OverlappedPresenter _presenter;

public void GetAppWindowAndPresenter() {
	var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
	WindowId myWndId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
	_apw = AppWindow.GetFromWindowId(myWndId);
	_presenter = _apw.Presenter as OverlappedPresenter;
}

and in the MainWindow contructor:

GetAppWindow();
_presenter.IsResizable = false;

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@martibravo
Comment options

@nickrandolph
Comment options

@martibravo
Comment options

@nickrandolph
Comment options

@rcohn
Comment options

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