下面展示的是在.net framework 4.5 中 ListBox的默认ItemContainerStyle, 样式模板中包含一些其它模板的默认属性值。
样式被应用到ListBox控件渲染出的每一个ListBoxItem条目上。 每一个ListBoxItem 条目的结构是由一个Border包含一个ContentPresenter组成。最重要的是,默认样式也包含了当移动鼠标或者选中条目时如何使用触发器去渲染条目样式。
<Style x:Key="lbDefaultItemContainerStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Padding" Value="4,1"/>
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FocusVisualStyle" Value="{StaticResource Fo