How to Filter more than one field using WPF AutoCompleteBox

一世执手 提交于 2019-12-08 10:06:41

问题


i am trying to customize the suggestions on the AutoCompleteBox in the WPF Tool kit. Right now i have a last name field which when the user enters characters a query runs that retrieves the top 10 records based on that last name. i would also like to filter by first name, i tried splitting out the comma and searching by the last name and the characters entered in the first name.

however, as soon as a space or comma is entered into the autocompletebox, the suggest functionality stops working, which I believe is because the ValueMemberPath property is set to be last name. Is there a work around for this, or a way to modify the ValueMemberPath to handle multiple values? Thanks!


回答1:


If you wont get any satisfied answer there's a nice control that I'm using from codeproject that supports searching by keywords with easy API.

WPFAutoCompleteTextbox




回答2:


There's another simple way to get Autocompletebox accept more than one Property for filtering: just use ValueMemberBinding like this:

ValueMemberBinding="{Binding Converter={StaticResource myConverter}}"

and define "myConverter" so that it concatenates your filter properties (properly separated) into a single string; now your AutocompleteBox will use the whole string as it was a single property.



来源:https://stackoverflow.com/questions/4555207/how-to-filter-more-than-one-field-using-wpf-autocompletebox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!