I faced one issue and I would really appreciate it if you could provide any advice for this.
Error message:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'TreeViewItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')
I have a treeview control (C# WPF .NET 4.0), and several items are added into this treeview by using datatemplate in xaml or manually, and both uses data binding.
When new data structure is received, I need to clean all items in treeview and regenerate new one by treeview_Control.Items.Clear()
and it seems working fine from GUI point of view, but when I see output window on Visual Studio it shows several error messages as like above.
I've tried to search for a solution and tried several methods but no luck yet. Someone just recommended to just ignore this error message, but I just really want to clear this up.
If you have any idea, please help me for this.