Skip to content

Fix Binding errors when Ribbon is outside of RibbonWindow - #11864

Open
vchaillou-arpege wants to merge 1 commit into
dotnet:mainfrom
vchaillou-arpege:fix/Ribbon-Binding-errors
Open

Fix Binding errors when Ribbon is outside of RibbonWindow#11864
vchaillou-arpege wants to merge 1 commit into
dotnet:mainfrom
vchaillou-arpege:fix/Ribbon-Binding-errors

Conversation

@vchaillou-arpege

@vchaillou-arpege vchaillou-arpege commented Aug 24, 2026

Copy link
Copy Markdown

Fixes #11860

Description

The Binding errors happened when using the default template for the Ribbon. It has two conditions that may try to bind to the parent RibbonWindow but it did not check if there was a parent RibbonWindow before, so the two Bindings ended up failing if the Ribbon was outside of a RibbonWindow.

This fix ensures that the Ribbon is hosted in a RibbonWindow before binding to the parent RibbonWidow by having a condition that binds to IsHostedInRibbonWindow first. if IsHostedInRibbonWindow == false, the following conditions are not evaluated.

FYI, this was already done this way there (and there).

Customer Impact

Without this PR, there will still be the Binding errors as described in #11860.

Regression

No (or at least not that I am aware of).

Testing

For now, I only tested with the simple case linked in #11860.

Risk

I believe that there are no real risks given the changes I made but correct me if I am wrong.

Microsoft Reviewers: Open in CodeFlow

@vchaillou-arpege
vchaillou-arpege requested review from a team and a lite review from Copilot August 24, 2026 14:48
@vchaillou-arpege
vchaillou-arpege requested a review from a team as a code owner August 24, 2026 14:48
@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 Aug 24, 2026

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

Updates Ribbon templates to avoid evaluating RibbonWindow ancestor bindings when the Ribbon is hosted elsewhere.

Changes:

  • Adds IsHostedInRibbonWindow guards to both affected multi-condition triggers.
  • Mirrors changes in source and generated theme XAML.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Themes/XAML/Ribbon.xaml Updated as part of this pull request.
src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Themes/Generic.xaml Updated as part of this pull request.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This ensures that the Ribbon is hosted in a RibbonWindow before binding
to the parent RibbonWidow, otherwise the Bindings may fail.

Fixes dotnet#11860
@vchaillou-arpege
vchaillou-arpege force-pushed the fix/Ribbon-Binding-errors branch 3 times, most recently from 00f8427 to fa28590 Compare August 24, 2026 15:15
@vchaillou-arpege

Copy link
Copy Markdown
Author

@dotnet-policy-service agree company="Arpège"

@miloush

miloush commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

RibbonWindow inherits Windows which is where the IsActive and WindowState properties are defined, why does the binding just not look for a Window?

@vchaillou-arpege

Copy link
Copy Markdown
Author

RibbonWindow inherits Windows which is where the IsActive and WindowState properties are defined, why does the binding just not look for a Window?

I guess this is because the Ribbon behaves slightly differently inside and outside of RibbonWindow. The two triggers that this PR fixes set properties on two elements that are placed differently in a RibbonWindow (PART_TitleHost and QatTopHost which is part of the Quick Access Toolbar) so I assume that these conditions are only valid inside RibbonWindows specifically. At least, that is the current behavior.

In a regular Window:
image

In a RibbonWindow:
image

Since this PR is solely about fixing Binding errors, I would rather not add any unneccessary change or any behavior change. So unless this is a requirement for merging, I would prefer not to touch these Bindings and keep the changes as minimal as possible.

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.

Binding errors when using a Ribbon outside of a RibbonWindow

3 participants