intercept RelativeSource FindAncestor
- by Pradeep
I have a WPF application which runs as a excel plugin, it has its visual tree like so
Excel
ElementHost
WPF UserControl
WPF ribbon bar control
Now any controls sitting on the WPF ribbon bar control are not enabled when the plugin is loaded within excel. See error below
System.Windows.Data Error: 4 : Cannot find source for binding with
reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Window', AncestorLevel='1''. BindingExpression:Path=IsActive; DataItem=null; target element
is 'Ribbon' (Name=''); target property is 'NoTarget' (type 'Object')
If I nest the ribbon bar control in a standalone Window(outside excel) it works fine.
Is there a way to intercept the FindAncestor call for a Window and wire it to something else.? Note that I cannot change the above binding as it isn't my control.