fluentribbon / Fluent.Ribbon

WPF Ribbon control like in Office
http://fluentribbon.github.io
MIT License
2.55k stars 516 forks source link

Cannot find source for binding: BindingExpression:Path=TitleBar.ActualHeight in Page #1210

Closed joergahmann closed 1 month ago

joergahmann commented 3 months ago

Binding-Errors with ribbon on page

**I have an Hamburger-App build with the template studio, in some Pages (not in the shell-window) I'm using a fluent.ribbon, which work fine. But I still get those annoying xaml-Errors for each Page:

System.Windows.Data Warning: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Fluent.IRibbonWindow', AncestorLevel='1''. BindingExpression:Path=TitleBar.ActualHeight; DataItem=null; target element is 'Ribbon' (Name=''); target property is 'QuickAccessToolBarHeight' (type 'Double')

System.Windows.Data Warning: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Fluent.IRibbonWindow', AncestorLevel='1''. BindingExpression:Path=TitleBar; DataItem=null; target element is 'Ribbon' (Name=''); target property is 'TitleBar' (type 'RibbonTitleBar')

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Window', AncestorLevel='1''. BindingExpression:Path=Background; DataItem=null; target element is 'QuickAccessToolBar' (Name='PART_QuickAccessToolBar'); target property is 'Background' (type 'Brush')

I know, I#m using a page, and fluent.ribbon needs a window, but is there chance to get rid off those warnings?**

best regards

Win11(64)

batzen commented 3 months ago

Hi there. Fluent.Ribbon doesn't need a window, but it's designed around the assumption that there is a window available. ;-)

To get rid of those warnings you can either set QuickAccessToolBarHeight and TitleBar on your Ribbon instance, or create a new style that is based on Fluent.Ribbon.Styles.Ribbon and set those values there. QuickAccessToolBarHeight has a default value of 23. TitleBar can be set to {x:Null}.

To get rid of the last warning you can override the style Fluent.Ribbon.Styles.QuickAccessToolbar and set the Background property there. This one will not be required starting with version 11 as i just removed it from the style as it wasn't required anyway.

joergahmann commented 3 months ago

Thanks a lot, I will try as soon I'm back home