How to Filter more than one field using WPF AutoCo

2019-06-14 02:28发布

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!

2条回答
混吃等死
2楼-- · 2019-06-14 02:36

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.

查看更多
太酷不给撩
3楼-- · 2019-06-14 02:53

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

查看更多
登录 后发表回答