Skip to content

Fix TabView windowing sample launch failure - #2160

Merged
Marcel W. (marcelwgn) merged 2 commits into
mainfrom
fix/tabview-sample-launch-2154
Apr 18, 2026
Merged

Marcel W. (marcelwgn) merged 2 commits into
mainfrom
fix/tabview-sample-launch-2154

Conversation

@niels9001

Copy link
Copy Markdown
Collaborator

Description

Note

This PR was generated with the assistance of GitHub Copilot (AI). All changes should be reviewed carefully.

Fixes #2154

The "Click here to launch the sample" button on the TabView page fails to open the windowing sample window.

Root cause

TabViewWindowingSamplePage uses Win32WindowHelper to set minimum window size via P/Invoke (SetWindowLongPtr to subclass the window procedure). This class uses static fields for oldWndProc and newWndProc, which causes crashes when multiple windows are involved — the same bug that PR #2007 fixed for other pages by introducing WindowHelper.SetWindowMinSize.

Fix

  • Replace Win32WindowHelper.SetWindowMinMaxSize() with WindowHelper.SetWindowMinSize() (uses OverlappedPresenter.PreferredMinimumWidth/Height)
  • Move the min-size setup to the Loaded event handler where XamlRoot is available
  • Remove the SetupWindowMinSize method and its callers
  • Remove unused DataIdentifier constant and Win32WindowHelper field

Validation

  1. Build: dotnet build WinUIGallery\WinUIGallery.csproj /p:Platform=x64 — 0 errors
  2. Navigate to TabView page → click "Click here to launch the sample" → window should open with 3 tabs
  3. Try resizing the sample window below 500x300 — it should enforce the minimum size
Niels Laute (niels9001) and others added 2 commits April 12, 2026 01:51
Replace Win32WindowHelper (P/Invoke with static fields) with the modern
WindowHelper.SetWindowMinSize (OverlappedPresenter API) for setting
minimum window size. The Win32WindowHelper caused crashes due to static
oldWndProc/newWndProc fields being shared across multiple windows.

The minimum window size is now set in the Loaded event handler where
XamlRoot is available, rather than before window activation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marcelwgn
Marcel W. (marcelwgn) enabled auto-merge (squash) April 18, 2026 13:14
@marcelwgn

Copy link
Copy Markdown
Contributor

/azp run

@marcelwgn
Marcel W. (marcelwgn) merged commit 696b619 into main Apr 18, 2026
4 checks passed
@marcelwgn
Marcel W. (marcelwgn) deleted the fix/tabview-sample-launch-2154 branch April 18, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants