我遇到了AutoCompleteBox篩選問題。SL4 AutoCompleteBox重複篩選結果問題
它似乎是rembering以前的過濾器。
例如我輸入「A」,它返回1個項目。我刪除'A'並輸入'Z',它應該返回1個項目。
問題是它返回'A'過濾器加上'Z'的結果,我刪除'Z'並輸入'S',它返回2個項目,現在顯示所有3個過濾器的結果。
我做錯了什麼?
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;
};
完美,謝謝。這是大都會主題爲我打破了 – 2012-07-09 12:53:29