Dragablz icon indicating copy to clipboard operation
Dragablz copied to clipboard

Error if AncestorType is not Window

Open grossmann opened this issue 8 years ago • 2 comments

I get the following errors if I place the TabablzControl not in a Window but in a UserControl.

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 'TabablzControl' (Name='ManualModeTabControl'); target property is 'Background' (type 'Brush')

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

It seems that AncestorType='System.Windows.Window' expects a window. Anyways it is working as expected but maybe this can have an effect in other use cases.

grossmann avatar Jul 26 '16 14:07 grossmann

Hi sorry, havent got to it. Could you please post a working, isolated test repo?

ButchersBoy avatar Nov 09 '16 23:11 ButchersBoy

I ended up setting the properties by hand to make the warnings go away...

Background="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=Background}" Foreground="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=Foreground}"

abhall724 avatar Jun 13 '17 19:06 abhall724