SL4 AutoCompleteBox重复筛选结果的问题 [英] SL4 AutoCompleteBox repeating filter results issue
问题描述
我在与AutoCompleteBox过滤的问题。
这似乎是rembering以前的过滤器。
例如我'A'类型,并将其返回1项。我删除了A,并输入'Z',这应该返回1项。
问题是,它从'A'过滤器+'Z返回结果',我删除了'Z'和式'S'这带回2项,现在会显示所有3对结果进行过滤。
我是不是做错了什么?
stockTypes.Add(新StockTypeDTO(){说明=钢卷,StockCode =SC});
stockTypes.Add(新StockTypeDTO(){说明=货盘钢卷,StockCode =PS});
stockTypes.Add(新StockTypeDTO(){说明=ZZZZZ,StockCode =ZZ});
<输入:AutoCompleteBox X:NAME =testautoFILTERMODE =自定义>
<输入:AutoCompleteBox.ItemTemplate>
<&DataTemplate的GT;
<&StackPanel的GT;
< ContentPresenter CONTENT ={绑定描述}/>
< / StackPanel的>
< / DataTemplate中>
< /输入:AutoCompleteBox.ItemTemplate>
< /输入:AutoCompleteBox>
testauto.ItemsSource = this.StockTypes;
testauto.ItemFilter =(搜索项)=>
{
StockTypeDTO stockType =项目作为StockTypeDTO;
如果(stockType!= NULL)
{
字符串过滤器= search.ToUpper(CultureInfo.InvariantCulture);
回报率(stockType.StockCode.ToUpper(CultureInfo.InvariantCulture)。载有(过滤器)
|| stockType.Description.ToUpper(CultureInfo.InvariantCulture)。载有(过滤器));
}
返回FALSE;
};
此外,以前的结果显示,而是像对待他们是不存在的吧?我的意思是,他们选择不改变autocompletebox的价值?
我有同样的问题,改变了样式之后得到了它。在我的情况是因为ListBox的风格。如果你正在使用的列表框自定义样式,请尝试删除它和放大器;使用默认的样式。
I'm having an issue with the AutoCompleteBox filtering.
It seems to be rembering the previous filter.
For example I type in 'A' and it returns 1 item. I delete the 'A' and type in 'Z' which should return 1 item.
The problem is it returns the results from the 'A' filter plus the 'Z', I delete 'Z' and type 'S' which brings back 2 items and it now 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;
};
Also, the previous results are shown, but treated like they are non-existent right? I mean, selecting them don't change the autocompletebox's value? I'm having the same issue, got it after changing the style. In my situation it's because of ListBox's style. If you're using a custom style for listbox, try removing it & use the default style.
这篇关于SL4 AutoCompleteBox重复筛选结果的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!