【问题标题】:Silverlight AutoCompleteBox on custom search自定义搜索中的 Silverlight AutoCompleteBox
【发布时间】:2011-10-06 17:58:55
【问题描述】:

我有这个对象:

public class Person
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string FullName
    {
        get { return string.Format("{0} {1}", FirstName, LastName); }
    }

    public override string ToString()
    {
        return "Person " + LastName;
    }
}

还有这个系列:

public ICollection<Person> Persons { get; set; }

我的自动完成框是:

<sdk:AutoCompleteBox ItemsSource="{Binding Persons}" FilterMode="Contains"
                                    SelectedItem="{Binding EmployeeSelected,Mode=TwoWay}"
                                 MinimumPrefixLength="2"/>

当我在 Persons 集合中搜索时,我想按名字搜索吗? AutoCompleteBox 中的哪个属性用于按 FirstName 进行搜索?

【问题讨论】:

    标签: silverlight autocompletebox


    【解决方案1】:

    使用ValueMemberPath

    <sdk:AutoCompleteBox ItemsSource="{Binding Persons}" FilterMode="Contains"
                                     SelectedItem="{Binding EmployeeSelected,Mode=TwoWay}"
                                     MinimumPrefixLength="2"
                                     ValueMemberPath="FirstName"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-21
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 2017-05-23
      • 2013-04-03
      • 2019-07-17
      • 2018-12-13
      相关资源
      最近更新 更多