Question

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?

Was it helpful?

Solution

Use ValueMemberPath :

<sdk:AutoCompleteBox ItemsSource="{Binding Persons}" FilterMode="Contains"
                                 SelectedItem="{Binding EmployeeSelected,Mode=TwoWay}"
                                 MinimumPrefixLength="2"
                                 ValueMemberPath="FirstName"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top