开发者

Silverlight AutoComplete TextBox Ignore special characters

I have an 开发者_如何学运维autocomplete box doing a search in my database. The sql command removes special characters but the textbox does not display the results because the returned results contain those special ones.

For example if i type in 1234 the sql server will return 1234 and 123-4 but the autocomplete box will only show 1234. Is there a way where i can get both to display?


You can set the ItemFilter property on the Autocomplex box to use your own custom filtering that would include the special characters. Something like:

//custom logic: how to autocomplete 
this.ItemFilter = (prefix, item) =>
{
   return item.ToString().Replace("-","").Contains(prefix);
};

Obviously you'd need to add more to it, but that should get you started.

EDIT: Thinking more about this after responding to comments, if your SQL server is already doing the filtering you want, then just set the AutoCompleteFilterMode to None. That should do the trick. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜