Skip to content

Fix TabView windowing sample launch failure#2160

Open
niels9001 wants to merge 2 commits intomainfrom
fix/tabview-sample-launch-2154
Open

Fix TabView windowing sample launch failure#2160
niels9001 wants to merge 2 commits intomainfrom
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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Full TabView sample doesn't launch

1 participant