问题描述
我有一个大的WPF应用程序,在某个时候,我们创建了很多对象(很多GUI绑定到带有许多子控件的新选择的对象上。
这会产生一堆绑定错误,有两种类型:
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 'ListBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor,AncestorLevel='1''. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ListBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')
(每个错误显示约10-20次)。
在询问之前,我一直在寻找解决方案,但是:
- 如果我使用snoop来查看GUI触发错误的部分,我将不再收到错误
- 寻找部分错误。我已经仔细检查过,但是我们在任何地方都没有绑定VerticalContentAlignment或它的水平副本,它总是绑定到给定的值
- 我找不到会丢失的绑定(也许是那些临时状态之一)
我有点迷路,看不到如何调试它?过去我们有很多绑定错误,现在希望没有错误,以便轻松查看我们正在开发的东西是否有问题。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)