Description
When using the Ribbon control in a regular Window (or any Window that is not a RibbonWindow) using the default template, there are two Binding errors in the output.
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Ribbon.RibbonWindow', AncestorLevel='1''. BindingExpression:Path=WindowState; DataItem=null; target element is 'Ribbon' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Ribbon.RibbonWindow', AncestorLevel='1''. BindingExpression:Path=IsActive; DataItem=null; target element is 'Ribbon' (Name=''); target property is 'NoTarget' (type 'Object')
These two errors appear harmless but can fill up the logs for the applications that keep track of Binding errors, like our applications do.
These errors do not appear when using the Ribbon in a RibbonWindow, but from my understanding using a Ribbon outside of a RibbonWindow still seems to be a valid scenario.
Reproduction Steps
Just use a Ribbon in a regular Window like this:
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApp1"
Title="MainWindow" Height="450" Width="800">
<Grid>
<!-- Ribbon that causes the error -->
<Ribbon />
</Grid>
</Window>
Expected behavior
As far as I can tell using a Ribbon outside of a RibbonWindow is a supported scenario, so I would expect to not have any error.
Actual behavior
There are two binding errors in the output:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Ribbon.RibbonWindow', AncestorLevel='1''. BindingExpression:Path=WindowState; DataItem=null; target element is 'Ribbon' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Ribbon.RibbonWindow', AncestorLevel='1''. BindingExpression:Path=IsActive; DataItem=null; target element is 'Ribbon' (Name=''); target property is 'NoTarget' (type 'Object')
Regression?
Not that I am aware of. I only tested on .NET 8 and 10 but from the looks of it, I don't think it is a regression.
Known Workarounds
Either:
- Overwrite the ControlTemplate for the Ribbon with a fixed one (the errors come from the default template, see "Other information")
- Ignore the errors
Impact
No noticeable impact for the end user, but it can fill up the logs for the applications that keep track of all the Binding errors.
Configuration
.NET 10.0.111, on Windows 11 x64
But I don't think it really matters for this issue.
Other information
The errors seem to come from the default template for the Ribbon, there are two conditions that try to bind on the parent RibbonWindow even when there is no parent RibbonWindow there and there.
We already have a fix internally and we intend to open a PR shortly to propose our fix.
Description
When using the Ribbon control in a regular Window (or any Window that is not a RibbonWindow) using the default template, there are two Binding errors in the output.
These two errors appear harmless but can fill up the logs for the applications that keep track of Binding errors, like our applications do.
These errors do not appear when using the Ribbon in a RibbonWindow, but from my understanding using a Ribbon outside of a RibbonWindow still seems to be a valid scenario.
Reproduction Steps
Just use a Ribbon in a regular Window like this:
Expected behavior
As far as I can tell using a Ribbon outside of a RibbonWindow is a supported scenario, so I would expect to not have any error.
Actual behavior
There are two binding errors in the output:
Regression?
Not that I am aware of. I only tested on .NET 8 and 10 but from the looks of it, I don't think it is a regression.
Known Workarounds
Either:
Impact
No noticeable impact for the end user, but it can fill up the logs for the applications that keep track of all the Binding errors.
Configuration
.NET 10.0.111, on Windows 11 x64
But I don't think it really matters for this issue.
Other information
The errors seem to come from the default template for the Ribbon, there are two conditions that try to bind on the parent RibbonWindow even when there is no parent RibbonWindow there and there.
We already have a fix internally and we intend to open a PR shortly to propose our fix.