문제

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,Mode=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"/>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top