I downloaded the new Silverlight Toolkit from CodePlex and used the AutoCompleteBox control on my recent Silverlight Datagrid app. It worked great, that is, after I struggled to figure out why it wasn’t.
My problem was that I was replacing a ComboBox control with an AutoCompleteBox and was trying to bind a collection to the AutoCompleteBox the same way I was binding it to the ComboBox.
This is how I was binding a collection to my custom ComboBox in a PreparingCellForEdit event.
MyComboBox employeeList = (MyComboBox)dg.CurrentColumn.GetCellContent(e.Row);
employeeList.ItemsSource = employees;
See the problem with attempting to set the AutoCompleteBox’s ItemsSource to employees, a collection of type JobEmployee? Right. AutoCompleteBox binds to an IEnumerable like a STRING list. Think AutoCompleteBox = List of Strings.
AutoCompleteBox emps = (AutoCompleteBox)dg.CurrentColumn.GetCellContent(e.Row);
var empString = (from c in employees
emps.ItemsSource = empString;
Thanks to this Tim Heuer post on using AutoCompleteBox with custom types that showed me the light.