【发布时间】:2011-02-13 11:42:10
【问题描述】:
如何在列表框上设置样式以在所选项目周围设置边框?
【问题讨论】:
标签: .net wpf xaml listbox border
如何在列表框上设置样式以在所选项目周围设置边框?
【问题讨论】:
标签: .net wpf xaml listbox border
最简单的方法是在ListBox的ItemContainerStyle中为IsSelected添加一个触发器
<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>
【讨论】:
FocusVisualStyle 可能就是你要找的东西。
【讨论】: