开发者

Silverlight AutoCompleteBox on custom search

开发者 https://www.devze.com 2023-04-11 01:06 出处:网络
I have this object : public class Person { public string FirstName { get; set; } public string LastName { get; set; }

I have this object :

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;
    }
}

And this Collecion:

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

My AutoCompleteBox is :

<sdk:AutoCompleteBox ItemsSource="{Binding Persons}" FilterMode="Contains"
                                    SelectedItem="{Binding EmployeeSelected,Mo开发者_如何学编程de=TwoWay}"
                                 MinimumPrefixLength="2"/>

When i search in the Persons collection i want search by FirstName? Which is the property in AutoCompleteBox for say search by FirstName?


Use ValueMemberPath :

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号