Wpf 您能解释一下为什么ItemsControl的DisplayMemberPath绑定不起作用吗?

Wpf 您能解释一下为什么ItemsControl的DisplayMemberPath绑定不起作用吗?,wpf,silverlight,dependency-properties,itemscontrol,Wpf,Silverlight,Dependency Properties,Itemscontrol,有人能解释一下为什么ItemsControl的DisplaymemberPath绑定不起作用吗 我用Reflector DisplayMemberPath检查了ItemsControl的唯一依赖属性,也检查了Bindable属性set only XAML: <ComboBox x:Name="display" DisplayMemberPath="{Binding NewAddress.TelePhone}" ItemsSource="{Binding Persons}"/>

有人能解释一下为什么ItemsControl的DisplaymemberPath绑定不起作用吗

我用Reflector DisplayMemberPath检查了ItemsControl的唯一依赖属性,也检查了Bindable属性set only

XAML:

  <ComboBox x:Name="display" DisplayMemberPath="{Binding NewAddress.TelePhone}" ItemsSource="{Binding Persons}"/>
public class Person
{
    public Person()
    {
        persons = new ObservableCollection<NewAddress>();
        persons.Add(new NewAddress() { TelePhone = "MyNo" });
        persons.Add(new NewAddress() { TelePhone = "MyNo1" });
        persons.Add(new NewAddress() { TelePhone = "MyNo2" });
        persons.Add(new NewAddress() { TelePhone = "MyNo3" });
    }

    private ObservableCollection<NewAddress> persons;

    public ObservableCollection<NewAddress> Persons
    {
        get { return persons; }
        set { persons = value; }
    }

}
 public class NewAddress
{
    public string  TelePhone { get; set; }
}

DisplayMemberPath是属性的实际名称,而不是属性的绑定。将XAML代码更改为以下内容:

<ComboBox x:Name="display" DisplayMemberPath="TelePhone" ItemsSource="{Binding Persons}"/>

DisplayMemberPath是属性的实际名称,而不是属性的绑定。将XAML代码更改为以下内容:

<ComboBox x:Name="display" DisplayMemberPath="TelePhone" ItemsSource="{Binding Persons}"/>


发布您的数据项。(我猜是person类)和Address Classic如果您省略了DiplayMemberPath,您是否至少获得了包含重复文本的行?请查看我编辑的问题。您的命名约定有严重问题。@HighCore:我只是出于简单的示例目的使用此命名约定,仅用于发布数据项。(我猜是个人类),还有地址类别如果您省略了DiplayMemberPath,您是否至少得到了包含重复文本的行?请查看我编辑过的问题。您的命名约定存在严重问题。@HighCore:我只是出于简单的示例目的才使用此命名约定,所以当我们将绑定设置为DisplayMemberPath时总是不起作用?@Ravuthasamy这是否解决了声明的问题?因此,当我们设置绑定到DisplayMemberPath时,总是不起作用?@Ravuthasamy这是否解决了声明的问题?