I have a problem with AutoCompleteBox filtering.
It seems to repeat the previous filter.
For example, I type "A" and returns 1 element. I delete “A” and type “Z”, which should return 1 element.
The problem is that it returns the results from the filter “A” plus “Z”, I delete “Z” and press “S”, which returns 2 elements, and now it displays the results from all 3 filters.
Am I doing something wrong?
stockTypes.Add(new StockTypeDTO() { Description = "Steel Coil", StockCode = "SC" });
stockTypes.Add(new StockTypeDTO() { Description = "Palletised Steel Coil", StockCode = "PS" });
stockTypes.Add(new StockTypeDTO() { Description = "ZZZZZ", StockCode = "ZZ" });
<input:AutoCompleteBox x:Name="testauto" FilterMode="Custom">
<input:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<ContentPresenter Content="{Binding Description}" />
</StackPanel>
</DataTemplate>
</input:AutoCompleteBox.ItemTemplate>
</input:AutoCompleteBox>
testauto.ItemsSource = this.StockTypes;
testauto.ItemFilter = (search, item) =>
{
StockTypeDTO stockType = item as StockTypeDTO;
if (stockType != null)
{
string filter = search.ToUpper(CultureInfo.InvariantCulture);
return (stockType.StockCode.ToUpper(CultureInfo.InvariantCulture).Contains(filter)
|| stockType.Description.ToUpper(CultureInfo.InvariantCulture).Contains(filter));
}
return false;
};
Steve source
share