【问题标题】:How to avoid the '[Unknown]' property does not point to a DependencyObject in path '(0).(1)[1].(2)' exception in wpf如何避免 '[Unknown]' 属性不指向路径 '(0).(1)[1].(2)' 中 wpf 异常中的 DependencyObject
【发布时间】:2011-12-11 19:20:54
【问题描述】:

点击按钮,更新ListBox ItemsSource 集合。 对于 4 或 5 次单击,它工作正常,但之后它会引发异常,因为 '[Unknown]' 属性不指向路径 '(0).(1)[1].(2)' 中的 DependencyObject

我用谷歌搜索并找到它的原因。

"ElementControl 覆盖 PrepareContainerForItemOverride 和 调用 PrepareModel 将网格插入到 _modelContainer 中 物品。稍后在 ElementFlow.BuildTargetPropertyPath (称为 通过 ElementFlow.SelectItemCore -> LayoutBase.SelectElement -> ElementFlow.PrepareTemplateStoryboard) 假设这样的网格 已插入 _modelContainer。当 网格尚未插入 _modelContainer。 WPF 调用 ApplyTemplate 上的 PrepareContainerForItemOverride。这只是完成 一次。以后添加的项目永远不会这样处理。 "

所以请给我一个解决方案来克服它。

【问题讨论】:

    标签: wpf exception dependencyobject


    【解决方案1】:

    您的“itemsource 集合”中似乎有一个不属于正确类型的项目,或者不包含您的列表框项目模板正在寻找的属性之一。或者,如果您的集合中有不同的类,其中一个可能没有您正在寻找的属性作为 DependencyProperty。如果它只是一个普通的属性,它可能无法正常工作。

    检查进入您的 itemssource 集合的所有对象类型,并确保它们都具有 DependencyProperties,这些 DependencyProperties 被命名为 itemstemplate 正在查找的内容。

    【讨论】:

      猜你喜欢
      • 2012-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-28
      • 2014-05-04
      • 2011-10-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多