[英]How do I change the color of the item focus rectangle on a WPF ListView? (not the item highlight color)
To change the appearance of the focus visual of an item in the ListView , you will have to manipulate the FocusVisualStyle
that is part of the ItemContainerStyle
used by the ListView . 若要更改ListView中某个项目的焦点视觉外观,您将必须操纵FocusVisualStyle
,它是ListView使用的ItemContainerStyle
一部分。
To illustrate, here is a simple example that turns the focus visual into a red dashed (dotted line) rectangle: 为了说明这一点,这是一个简单的示例,将焦点视觉变为红色的虚线(虚线)矩形:
<ListView ...>
<ListView.ItemContainerStyle>
<!-- This is the style used by the item container of this ListView -->
<Style TargetType="ListViewItem">
<Setter Property="FocusVisualStyle">
<Setter.Value>
<!-- This is the style for the focus visual -->
<Style>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle SnapsToDevicePixels="true"
Stroke="Red"
StrokeThickness="1"
StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.