Fix Binding errors when Ribbon is outside of RibbonWindow - #11864
Fix Binding errors when Ribbon is outside of RibbonWindow#11864vchaillou-arpege wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Updates Ribbon templates to avoid evaluating RibbonWindow ancestor bindings when the Ribbon is hosted elsewhere.
Changes:
- Adds
IsHostedInRibbonWindowguards 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
00f8427 to
fa28590
Compare
|
@dotnet-policy-service agree company="Arpège" |
|
|
I guess this is because the 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. |


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
IsHostedInRibbonWindowfirst. ifIsHostedInRibbonWindow == 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