【问题标题】:AmbiguousMatchException when Binding to default property in WPF绑定到 WPF 中的默认属性时出现 AmbiguousMatchException
【发布时间】:2023-04-05 01:15:01
【问题描述】:

以下 XAML 会产生 AmbiguousMatchException。 myText 的 DataContext 是一个由 > 1 行组成的 DataTable,其中包含一个名为“test”的 DataColumn:

<TextBox Name="myText" Text="{Binding Path=Rows[0].Item[test]}"/>

当我将绑定路径语法修改为以下示例时,绑定按预期工作:

<TextBox Name="myText" Text="{Binding Path=Rows[0][test]}"/>

鉴于 DataTable 的名称是“myData”,以下两行代码都引用了第 0 行的“test”列的内容:

myData.Rows(0)("test")    
myData.Rows(0).Item("test")

为什么显式命名 Item 属性的语法似乎在绑定场景中不起作用?

【问题讨论】:

    标签: wpf vb.net data-binding


    【解决方案1】:

    当集合的某些部分在 xaml 绑定中具有不同的评估方式时的索引属性,然后是从代码调用时的索引属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多