【问题标题】:WPF: ComboBox DisplayMemberPath is suddenly not shown anymore?WPF:ComboBox DisplayMemberPath 突然不再显示?
【发布时间】:2010-05-15 20:34:50
【问题描述】:

在我的 ComboBox 中,我看到 3 次:MyNameSpace.ViewModel.CustomerViewModel ??

实际上这段代码有效,但现在不知道我改变了什么:

      <ComboBox  DisplayMemberPath="{Binding Path=CustomerName}" SelectedIndex="0" ItemsSource="{Binding CustomersViewModel}" />

Customers 是一个 ObservableCollection

同样的代码适用于仅使用 DisplayMemberBinding 而不是 DisplayMemberPath 的 ListBox。

怎么了?

【问题讨论】:

    标签: wpf data-binding combobox namespaces


    【解决方案1】:

    DisplayMemberPath 采用路径,而不是绑定。所以只需设置 DisplayMemberPath="CustomerName"。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-29
      • 1970-01-01
      • 1970-01-01
      • 2022-08-17
      • 2015-05-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多