Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 205
Teaman Avatar asked Dec 04 '13 14:12

Teaman


1 Answers

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'

like image 193
Natalie Tay Avatar answered Oct 04 '22 17:10

Natalie Tay