开发者

Silverlight AutoCompleteBox on custom search

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜