在WPF中去除ListBox项的单击样式,可以通过修改ItemContainerStyle来实现。以下是解决方案:
<ListBox>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border Background="{TemplateBinding Background}">
<ContentPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
这段代码通过自定义ListBoxItem的ControlTemplate移除了默认的点击效果样式,同时将背景设为透明。你可以根据需要进一步调整边框和内容展示样式。