Kia*_*eng 1 c# wpf custom-controls wpf-controls
我有一个定制风格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>
Run Code Online (Sandbox Code Playgroud)
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/> ....
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1518 次 |
| 最近记录: |