Ribbon binding failures when used within a regular Window (not a RibbonWindow)
Asked Answered
B

2

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?

Bluepoint answered 4/12, 2013 at 14:46 Comment(3)
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.Bluepoint
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.Nitty
Possible duplicate of Cannot find source for binding with reference with RibbonComboBoxNitty
U
-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'

Used answered 6/12, 2013 at 5:28 Comment(2)
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.Bluepoint
May be I misunderstand Your answer, but it seems your advice is not to mind those binding issues.Bluepoint
E
-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

Endomorphism answered 9/2, 2015 at 12:33 Comment(2)
if I could use RibbonWindow there would be no questions. My question says "I can't use RibbonWindow for some presentation-compatibility issues"Bluepoint
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 itEndomorphism

© 2022 - 2024 — McMap. All rights reserved.