How do i set a style on the listbox to get a border around the selected item ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The easiest way is to add a Trigger for IsSelected
in the ItemContainerStyle for the ListBox
<ListBox ...>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="BorderBrush" Value="Red"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderThickness" Value="1"/>
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
<!--...-->
</ListBox>
回答2:
FocusVisualStyle may be what are you looking for.