问题描述
大多数列表框允许您通过键入显示文本的首字母来查找其中的项目.如果键入的字母匹配多个项目,则可以继续添加字母以缩小搜索范围.
Most list boxes allow you to find items within them by typing the first letters of the displayed text. If the typed letters match multiple items, then you can keep adding letters to narrow the search.
我需要在 WPF ListBox 中执行此操作.但是,这些项目不是纯字符串——它们是我使用 DataTemplate 呈现的自定义对象.我希望有一种方法可以提供字符串值的路径,该路径应该用于 ListBox 项的文本键盘导航.
I need to do this in a WPF ListBox. However, the items aren't plain strings -- they're custom objects that I present using a DataTemplate. I'm hoping that there's a way I can provide a path to the string value that should be used for this textual keyboard navigation of the ListBox items.
这怎么可能?
推荐答案
您可以尝试将 IsTextSearchEnabled 设置为 true 并使用 TextSearch.TextPath 附加属性.
You could try setting IsTextSearchEnabled to true and using the TextSearch.TextPath attached property.
例如
<ListBox IsTextSearchEnabled="True"
TextSearch.TextPath="CustomObject.StringProperty"/>
这篇关于如何通过键入在 WPF ListBox 中找到项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)