SPCode icon indicating copy to clipboard operation
SPCode copied to clipboard

System.Windows.Data error 4: cannot find source for binding with reference

Open maxijabase opened this issue 4 years ago • 0 comments

This spammy error in the VS Immediate Window happens when the program closes the ISAC window and executes the InterruptLoadAutoCompletes function located in EditorElementIntellisenseController.cs, more specifically, when both the AutoCompleteBox and MethodAutoCompleteBox's ItemSources get refreshed.

I managed to pull this little comment from one of MahApps Metro's documentation files:

<member name="M:MahApps.Metro.Controls.TabControlHelper.ClearStyle(System.Windows.Controls.TabItem)">
	 Sets the Style and Template property to null.
	 
	 Removing a TabItem in code behind can produce such nasty output
	 System.Windows.Data Warning: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.TabControl', AncestorLevel='1''. BindingExpression:Path=Background; DataItem=null; target element is 'TabItem' (Name=''); target property is 'Background' (type 'Brush')
	 or
	 System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.TabControl', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'TabItem' (Name=''); target property is 'UnderlineBrush' (type 'Brush')
	
	 This is a timing problem in WPF of the binding mechanism itself.
	
	 To avoid this, we can set the Style and Template to null.
</member>

maxijabase avatar Dec 01 '21 03:12 maxijabase