Skip to content

Refactor MeasureCore and fix measurement for using WindowDrawnDecorations with Styles#21572

Open
Fachep wants to merge 2 commits into
AvaloniaUI:mainfrom
Fachep:fix_window_decorations
Open

Refactor MeasureCore and fix measurement for using WindowDrawnDecorations with Styles#21572
Fachep wants to merge 2 commits into
AvaloniaUI:mainfrom
Fachep:fix_window_decorations

Conversation

@Fachep

@Fachep Fachep commented Jun 12, 2026

Copy link
Copy Markdown

What does the pull request do?

This PR moves ApplyStyling earlier in Layoutable.MeasureCore.

What is the current behavior?

Layoutable.MeasureCore currently applies styling after checking visibility, even though styling may affect the control's visibility.

Due to this, if a style in Window.Styles sets the IsVisible property of a control inside WindowDrawnDecorationsContent to false, the control is hidden but still reports its full size during the first measurement pass.

What is the updated/expected behavior with this PR?

Layoutable.MeasureCore now applies styling before performing visibility checks and measurement.

Controls hidden via styles now correctly produce an empty desired size in the same scenario. A unit test has been added to verify this behavior.

Checklist

Fixed issues

Fixes #21570

Copilot AI review requested due to automatic review settings June 12, 2026 14:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR fixes a layout/measurement issue where styling (e.g., setting IsVisible=false via styles) was not applied early enough to influence measurement, particularly for drawn window decorations.

Changes:

  • Added a unit test covering measurement of WindowDrawnDecorationsContent when styling hides a control.
  • Adjusted Layoutable.MeasureCore to apply styling before checking IsVisible, ensuring style-driven visibility changes are respected during measure.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/Avalonia.Controls.UnitTests/WindowTests.cs Adds regression test ensuring styled visibility affects measurement of drawn decoration overlay content.
src/Avalonia.Base/Layout/Layoutable.cs Applies styling earlier in measure so style changes (like visibility) take effect before measurement logic runs.

Comment thread src/Avalonia.Base/Layout/Layoutable.cs Outdated
Comment thread tests/Avalonia.Controls.UnitTests/WindowTests.cs Outdated
Comment thread tests/Avalonia.Controls.UnitTests/WindowTests.cs Outdated
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0066351-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@cla-avalonia

cla-avalonia commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator
  • All contributors have signed the CLA.

@Fachep

Fachep commented Jun 12, 2026

Copy link
Copy Markdown
Author

@cla-avalonia agree

@Fachep Fachep changed the title Refactor MeasureCore and add unit test for WindowDrawnDecorations with Styles Refactor MeasureCore and add fix measurement for using WindowDrawnDecorations with Styles Jun 13, 2026
@Fachep
Fachep marked this pull request as draft June 13, 2026 13:59
@Fachep
Fachep force-pushed the fix_window_decorations branch from d6bd477 to be536ed Compare June 13, 2026 18:45
@Fachep
Fachep marked this pull request as ready for review June 13, 2026 18:46
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0066393-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@Fachep Fachep changed the title Refactor MeasureCore and add fix measurement for using WindowDrawnDecorations with Styles Refactor MeasureCore and fix measurement for using WindowDrawnDecorations with Styles Jun 16, 2026
@Fachep
Fachep force-pushed the fix_window_decorations branch from be536ed to 232d415 Compare June 17, 2026 09:33
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0066581-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@Fachep

Fachep commented Jun 17, 2026

Copy link
Copy Markdown
Author

I have no idea about the failed integration test. It was the Windows test last time, after rebase to master it becomes the Mac test this time...

@Fachep
Fachep force-pushed the fix_window_decorations branch from 232d415 to 7e7334f Compare July 7, 2026 01:14
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0067229-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@Fachep

Fachep commented Jul 7, 2026

Copy link
Copy Markdown
Author

@MrJul Can you review this pls?

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.

Layout measurement issue for controls in WindowDrawnDecorationsContent when IsVisible=false is applied through Window.Styles

4 participants