Skip to content

Fix ToolBarTray negative measure constraint#11648

Open
eolivesjoe wants to merge 1 commit into
dotnet:mainfrom
eolivesjoe:fix/2189-toolbartray-measureoverride-exception
Open

Fix ToolBarTray negative measure constraint#11648
eolivesjoe wants to merge 1 commit into
dotnet:mainfrom
eolivesjoe:fix/2189-toolbartray-measureoverride-exception

Conversation

@eolivesjoe
Copy link
Copy Markdown

@eolivesjoe eolivesjoe commented May 19, 2026

Fixes #2189

Description

ToolBarTray.MeasureOverride used DoubleUtil.LessThan(remainingLength, 0) when deciding whether to clamp remainingLength to zero.

Because DoubleUtil.LessThan uses an epsilon comparison, a very small negative value may not be treated as less than zero. That value can then be used as a measure constraint, which can result in an ArgumentException.

This changes the guard to use a direct negative check so any negative remainingLength is clamped before it is used during measure.

Customer Impact

Customers can hit an ArgumentException during ToolBarTray layout measurement when floating-point rounding leaves remainingLength slightly negative.

Regression

No.

Testing

Built locally with .\build.cmd

Risk

Low. The change is limited to ToolBarTray.MeasureOverride and only affects negative remainingLength values.

Microsoft Reviewers: Open in CodeFlow

@eolivesjoe eolivesjoe requested a review from a team May 19, 2026 04:11
@dotnet-policy-service dotnet-policy-service Bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.ArgumentException in PresentationFramework.dll!System.Windows.Controls.ToolBarTray.MeasureOverride

1 participant