In my application, I use the WPF autocomplete field from wpf toolkit. I implement it using the MVVM pattern. Binding works fine, but I have a little problem trying to clear the autocomplete content. Setting the associated property in the viewmodel to null clears the text only partially (all the text entered from the keyboard is not cleared - that is, if I enter CH when retrieving all cities and select Chicago and set the bound property to null, CH is not cleared, the rest is ICAGO.)
XAML is as follows:
<my:AutoCompleteBox Grid.Row="0"
Grid.Column="1"
HorizontalAlignment="Left"
Margin="0,6,0,0"
Name="acTown"
SelectedItem="{Binding NewTown, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ValueMemberBinding="{Binding Converter={StaticResource TownConverter}}"
Populating="Populating"
VerticalAlignment="Top"
Height="Auto"
</my:AutoCompleteBox>
Method in the viewport to clear the field:
public void ClearTown()
{
NewTown = null;
OnPropertyChanged("NewTown");
}
I canβt understand what is wrong with the code, or is it just a mistake in autocompletebox?
: Silverlight AutoCompleteBox SearchText MVVM, . , SearchText AutoCompleteBox, readonly setter