После этого кажется, что он не имеет ничего общего с DataGridTemplateColumn, а скорее с AutoCompleteBox из Wpf Toolkit. AutoCompleteBox стал для меня ничем иным, как проблемой с тех пор, как я начал его использовать. В результате я решил отказаться от него и использовать вместо него Editable ComboBox. Combobox намного чище и проще в применении. Вот как теперь выглядит мой код, и datarowview может видеть, что пользователь вводит в поле:
<DataGridTemplateColumn Header="Account Type">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path='Account Type'}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox IsEditable="True" LostFocus="LostFocusAccountTypes" ItemsSource="{DynamicResource types}" Height="23" IsTextSearchEnabled="True"/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
Code Behind (this.Types - это наблюдаемая коллекция строк)
private void PopulateAccountTypes()
{
try
{
string accountQuery = "SELECT AccountType FROM AccountType WHERE UserID = " + MyAccountant.DbProperties.currentUserID + "";
SqlDataReader accountType = null;
SqlCommand query = new SqlCommand(accountQuery, MyAccountant.DbProperties.dbConnection);
accountType = query.ExecuteReader();
while (accountType.Read())
{
this.Types.Add(accountType["AccountType"].ToString());
}
accountType.Close();
Resources["types"] = this.Types;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}