Skip to content

fix: TitleBar respects ResizeMode.NoResize#1719

Open
xyliteee wants to merge 4 commits into
lepoco:mainfrom
xyliteee:main
Open

fix: TitleBar respects ResizeMode.NoResize#1719
xyliteee wants to merge 4 commits into
lepoco:mainfrom
xyliteee:main

Conversation

@xyliteee
Copy link
Copy Markdown

Add ResizeMode check in GetWindowBorderHitTestResult. Return HTNOWHERE when ResizeMode is not CanResize or CanResizeWithGrip. Fixes regression introduced by PR #1560 where NoResize windows remained resizable.

Pull request type

Please check the type of change your PR introduces:

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

When a FluentWindow has ResizeMode="NoResize" (or CanMinimize) and contains a TitleBar with ExtendsContentIntoTitleBar="True", the window can still be resized by dragging its borders.

This is because GetWindowBorderHitTestResult() returns resize hit-test values (HTLEFT/HTRIGHT/HTTOP/HTBOTTOM etc.) without checking the window's ResizeMode property.

Issue Number: N/A

What is the new behavior?

  • Adds a ResizeMode check at the beginning of GetWindowBorderHitTestResult()
  • Returns IntPtr.Zero (HTNOWHERE) when ResizeMode is not CanResize or CanResizeWithGrip
  • Windows with ResizeMode="NoResize" or ResizeMode="CanMinimize" can no longer be resized via border dragging
  • Preserves normal resize behavior for CanResize and CanResizeWithGrip

Other information

Affected versions: v4.1.0 - v4.3.0 (regression introduced by PR #1560)

Tested on: v4.3.0

Minimal repro XAML:

<ui:FluentWindow ResizeMode="NoResize" ExtendsContentIntoTitleBar="True">
    <ui:TitleBar/>
</ui:FluentWindow>

Add ResizeMode check in GetWindowBorderHitTestResult.
Return HTNOWHERE when ResizeMode is not CanResize or CanResizeWithGrip.
Fixes regression introduced by PR lepoco#1560 where NoResize windows remained resizable.
@xyliteee xyliteee requested a review from pomianowski as a code owner May 15, 2026 12:08
@github-actions github-actions Bot added controls Changes to the appearance or logic of custom controls. PR Pull request dotnet release titlebar Titlebar updates labels May 15, 2026
@pomianowski pomianowski changed the title Fix: TitleBar respects ResizeMode.NoResize fix: TitleBar respects ResizeMode.NoResize May 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression in TitleBar non-client hit-testing so windows with ResizeMode="NoResize" (or CanMinimize) cannot be resized via border dragging when ExtendsContentIntoTitleBar=True.

Changes:

  • Adds a ResizeMode gate to GetWindowBorderHitTestResult to return HTNOWHERE when the window is not resizable.

Comment thread src/Wpf.Ui/Controls/TitleBar/TitleBar.WindowResize.cs Outdated
Comment thread src/Wpf.Ui/Controls/TitleBar/TitleBar.WindowResize.cs Outdated
Comment on lines +48 to +52
var window = Window.GetWindow(this);
if (window?.ResizeMode != ResizeMode.CanResize && window?.ResizeMode != ResizeMode.CanResizeWithGrip)
{
return IntPtr.Zero;
}
xyliteee and others added 2 commits May 24, 2026 12:54
Return PInvoke.HTNOWHERE explicitly instead of IntPtr.Zero when resize is disabled

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Use existing _currentWindow cache for ResizeMode check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

controls Changes to the appearance or logic of custom controls. dotnet PR Pull request release titlebar Titlebar updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants