intercept RelativeSource FindAncestor

Posted by Pradeep on Stack Overflow See other posts from Stack Overflow or by Pradeep
Published on 2010-03-08T15:15:20Z Indexed on 2010/04/04 22:43 UTC
Read the original article Hit count: 694

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.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about wpf-controls