【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

posted @ 2018-02-05 15:44  oiliu  阅读(1666)  评论(0编辑  收藏  举报