我有这个对象:
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;
}
}
这个Collecion:
public ICollection<Person> Persons { get; set; }
我的自动完成框是:
<sdk:AutoCompleteBox ItemsSource="{Binding Persons}" FilterMode="Contains"
SelectedItem="{Binding EmployeeSelected,Mode=TwoWay}"
MinimumPrefixLength="2"/>
当我在Persons集合中搜索时,我希望通过FirstName进行搜索? 哪个是AutoCompleteBox中的属性,比如用FirstName搜索?
答案 0 :(得分:1)
使用ValueMemberPath
:
<sdk:AutoCompleteBox ItemsSource="{Binding Persons}" FilterMode="Contains"
SelectedItem="{Binding EmployeeSelected,Mode=TwoWay}"
MinimumPrefixLength="2"
ValueMemberPath="FirstName"/>