PersonVM.cs
public class MainWindowVM
{
public MainWindowVM()
{
PersonList = new ObservableCollection(Employees);
}
See my answer to this question: Can I do Text search with multibinding
Unfortunately TextSearch.Text doesn't work in a DataTemplate. I think you have two options here
Option 1. Set IsTextSearchEnabled to True for the ComboBox, override ToString in your source class and change the MultiBinding in the TextBlock to a Binding
<ComboBox ...
IsTextSearchEnabled="True">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
public class Person
{
public override string ToString()
{
return String.Format("{0} | {1}", Name, ID);
}
public string Name { get; set; }
public int ID { get; set; }
}
Option 2. Make a new Property in your source class where you combine Name and ID for the TextSearch.TextPath
. Also, you should call OnPropertyChanged
for NameAndId
whenever you do it for Name
or ID
<ComboBox ...
TextSearch.TextPath="NameAndId"
IsTextSearchEnabled="True">
public string NameAndId
{
return String.Format("{0} | {1}", Name, ID);
}