8
votes

I'm using a Ribbon control from RibbonControlLibrary for .net 3.5.

I can't use RibbonWindow for some presentation-compatibility issues. So I place a Ribbon control inside Window.

There are no visible issues, but I'm getting 2 error messages in my VisualStudio output window.

Those messages are:

  1. System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Microsoft.Windows.Controls.Ribbon.RibbonWindow', AncestorLevel='1''. BindingExpression:Path=WindowState; DataItem=null; target element is 'Ribbon' (Name=''); target property is 'NoTarget' (type 'Object')

  2. System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Microsoft.Windows.Controls.Ribbon.RibbonWindow', AncestorLevel='1''. BindingExpression:Path=IsActive; DataItem=null; target element is 'Ribbon' (Name=''); target property is 'NoTarget' (type 'Object')

This can be reproduced just adding a Ribbon to a Window and running the application.

Is there a way to tell Ribbon not to try to bind anything exactly to RibbonWindow but for Window?

2
I DO NOT use RibbonWindow, I place a Ribbon onto regular WPF Window, that's the point. RibbonWindow looks and behaves a bit different and those difference is unacceptable in my app.Teaman
I'm using System.Windows.Controls.Ribbon against .NET 472 and its the same. But I'm not sure if these errors cause any real issues.StayOnTarget

2 Answers

1
votes

Since you said you can't use RibbonWindow (for some reason...), I am assuming you're doing something like

<Window x:Class="Yournamespace" ...>
    <Ribbon>
    </Ribbon>
</Window>

Your ancestor should be AncestorType='System.Windows.Window' and not 'Microsoft.Windows.Controls.Ribbon.RibbonWindow'

-2
votes

You probably have:

<Window x:Class="yournamespace" 
    xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
...>
    <r:Ribbon>
    </r:Ribbon>
</Window>

To fix this just replace <Window> and </Window> with <r:RibbonWindow> and </r:RibbonWindow>

this fixed it for me