我有一个自定义样式ListBoxItem
,Border
围绕着ContentPresenter
。 (代码见下文)。我的边框充当我的选择指示器,当您选择它时会变为灰色。当我使用鼠标时一切都很好,但是当我使用键盘时,会出现一个丑陋的虚线灰色边框。我该如何删除它?
您可以看到,当我鼠标悬停/点击ListBoxItem
时,包含背景的边框会围绕该项目。但是当我使用键盘时,会出现一个丑陋的虚线边框。
<Style x:Key="{x:Type ListBoxItem}" TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<StackPanel>
<Border Name="HighlightBorder"
Padding="30"
BorderBrush="Transparent"
BorderThickness="1"
CornerRadius="5"
>
<ContentPresenter/>
</Border>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="HighlightBorder" Property="Background" Value="#F3F3F3"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="HighlightBorder" Property="Background" Value="#DFDFDF"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter TargetName="HighlightBorder" Property="Background" Value="#DFDFDF"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>