9

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?

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Teaman
  • 177
  • 6
  • 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 Feb 11 '15 at 07:38
  • 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 Apr 18 '19 at 19:21
  • Possible duplicate of [Cannot find source for binding with reference with RibbonComboBox](https://stackoverflow.com/questions/38842134/cannot-find-source-for-binding-with-reference-with-ribboncombobox) – StayOnTarget Apr 22 '19 at 12:40

2 Answers2

-1

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'

Sheridan
  • 68,826
  • 24
  • 143
  • 183
Natalie Tay
  • 133
  • 12
  • I understand the reason, but I don't know how to solve the issue. AFAIK some control's template inside Ribbon can be overridden in the outer style to make it look at AncestorType of Window instead of RibbonWindow. – Teaman Dec 06 '13 at 12:16
  • May be I misunderstand Your answer, but it seems your advice is not to mind those binding issues. – Teaman Dec 06 '13 at 12:20
-3

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

Olivier
  • 20
  • 1
  • 2
    if I could use RibbonWindow there would be no questions. My question says "I can't use RibbonWindow for some presentation-compatibility issues" – Teaman Feb 09 '15 at 13:09
  • If you could give an example of your basic code when you use ribbonwindow and the error it generates, we could maybe see where stuff goes wrong. For me the error went away when I used ribbonwindow. I find it strange that you can't use it – Olivier Feb 11 '15 at 11:33