如何使用 WPF AutoCompleteBox 筛选多个字段
我正在尝试自定义 WPF 工具包中 AutoCompleteBox 上的建议。现在我有一个姓氏字段,当用户输入字符时,将运行一个查询,根据该姓氏检索前 10 条记录。我还想按名字过滤,我尝试拆分逗号并按姓氏和名字中输入的字符进行搜索。
但是,一旦在自动完成框中输入空格或逗号,建议功能就会停止工作,我认为这是因为 ValueMemberPath 属性设置为姓氏。是否有解决此问题的方法,或者修改 ValueMemberPath 以处理多个值的方法?谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您没有得到任何满意的答案,我正在使用来自 codeproject 的一个很好的控件,它支持使用简单的 API 按关键字搜索。
WPFAutoCompleteTextbox
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
还有另一种简单的方法可以让 Autocompletebox 接受多个属性进行过滤:只需像这样使用 ValueMemberBinding:
并定义“myConverter”,以便它将您的过滤器属性(正确分隔)连接到单个字符串中;现在您的 AutocompleteBox 将使用整个字符串,因为它是单个属性。
There's another simple way to get Autocompletebox accept more than one Property for filtering: just use ValueMemberBinding like this:
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.