Ribbon from RibbonControlLibrary binding failures

Teaman Source

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 Ribbon to Window and running the application.

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

wpfbinding.net-3.5ribbon

Answers

answered 5 years ago Natalie Tay #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'

answered 4 years ago Olivier #2

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

comments powered by Disqus