Locating binding errors

Posted by softengine on Stack Overflow See other posts from Stack Overflow or by softengine
Published on 2010-04-09T18:10:51Z Indexed on 2010/04/09 18:13 UTC
Read the original article Hit count: 510

I'm dealing with a large WPF application that is outputting a large number of binding errors. A typical error looks like this:

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 'MenuItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')

Problem is I don't know where in the app this is coming from. Searching the entire solution for AncestorType={x:Type ItemsControl} doesn't necessary help since I still don't know which result is the culprit. I've tried setting PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.All; but the extra information doesn't help locate the problematic bindings. File names and line numbers is really what I need. Is there anyway to get this information?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about wpf-binding