【问题标题】:Silverlight Data and Element BindingSilverlight 数据和元素绑定
【发布时间】:2011-07-14 02:28:07
【问题描述】:

这两者有什么区别?

DataContext="{Binding SelectedItem, ElementName=listBoxStudents}

DataContext="{Binding ElementName=listBoxStudents, Path=SelectedItem}

在 Apress Pro Silverlight 4 中,第二个示例是一个简单的元素到元素绑定。 我认为第一个示例与数据绑定有关。

在我的应用程序中,它们也是如此。 有人可以澄清一下吗?

【问题讨论】:

    标签: c# silverlight binding


    【解决方案1】:

    您提出的两行含义完全相同。它们都指定了到名称为listBoxStudents 的元素的SelectedItem 属性的绑定。

    如果Path 属性在您的{Binding ...} 中排在第一位,您可能会错过Path= 部分。除此之外,{Binding ...} 中的属性顺序并不重要。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-25
      • 2011-04-26
      • 2011-01-30
      • 2011-01-27
      • 2011-07-31
      • 2013-07-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多