WPF:删除样式列表框中焦点项目周围的虚线边框 [英] WPF: Remove dotted border around focused item in styled listbox
本文介绍了WPF:删除样式列表框中焦点项目周围的虚线边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有自定义控件模板的水平列表框.选中的项目在聚焦时会出现一个虚线框.有谁知道如何摆脱它?
I have a horizontal listbox with a custom controlIemplate. The selected item gets a dotted frame when focused. Anyone know how to get rid of it?
推荐答案
您需要将每个 ListBoxItem 的 FocusVisualStyle 设置为 null.步骤如下
You need to set FocusVisualStyle of each ListBoxItem to null. Steps are bellow
1) 为 ListBox 创建 ItemContainerStyle
1) Create ItemContainerStyle for the ListBox
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/> ....
2) 将该样式设置为列表框
2) Set that style to Listbox
<ListBox ItemContainerStyle="{DynamicResource ListBoxItemStyle1}"
这篇关于WPF:删除样式列表框中焦点项目周围的虚线边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文