【WPF】Listbox内item的样式替换默认选中样式和鼠标滑过样式
1 <Style TargetType="ListBoxItem" x:Key="oiliu"> 2 <!-- 设置控件模板 --> 3 <Setter Property="Template"> 4 <Setter.Value> 5 <ControlTemplate TargetType="ListBoxItem"> 6 <Border Background="{TemplateBinding Background}" Padding="0" Margin="4,0,0,0"> 7 <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 8 VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 9 TextBlock.Foreground="{TemplateBinding Foreground}"/> 10 </Border> 11 </ControlTemplate> 12 </Setter.Value> 13 </Setter> 14 </Style>
TargetType