In the AutoCompleteBox source code (downloadable from Microsoft), I found the following:
private void OnSelectedItemChanged(object newItem)
{
string text;
if (newItem == null)
{
text = SearchText;
}
else
{
text = FormatValue(newItem, true);
}
UpdateTextValue(text);
if (TextBox != null && Text != null)
{
TextBox.SelectionStart = Text.Length;
}
}
What bothers me is the line {text = SearchText;}. If I associate the SelectedItem with my ViewModel and after writing the search to the AutoCompleteBox, the SearchText is not empty, then when the underlying reset data is null, the AutoCompleteBox can display the SearchText instead of an empty string. Can someone explain why this is written this way and suggest a workaround?
source
share