Files
HandyControl/Net35/HandyControl_Net35/Themes/Styles/ListBox.xaml
T
2019-01-21 00:43:10 +08:00

53 lines
2.8 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Base/ListBoxBaseStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!--默认样式-->
<Style BasedOn="{StaticResource ListBoxBaseStyle}" TargetType="ListBox"/>
<Style x:Key="ListBoxItemStyle" TargetType="ListBoxItem">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType=ItemsControl}}"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ListBoxItemFullStyle" BasedOn="{StaticResource ListBoxItemStyle}" TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Height" Value="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=ItemsControl}}"/>
</Style>
<ItemsPanelTemplate x:Key="WrapPanelItemsPanelTemplate">
<WrapPanel FocusVisualStyle="{x:Null}"/>
</ItemsPanelTemplate>
<Style x:Key="WrapPanelListBox" BasedOn="{StaticResource ListBoxBaseStyle}" TargetType="ListBox">
<Setter Property="ItemsPanel" Value="{StaticResource WrapPanelItemsPanelTemplate}"/>
<Setter Property="ItemContainerStyle" Value="{StaticResource ListBoxItemStyle}"/>
</Style>
<ItemsPanelTemplate x:Key="StackPanelItemsPanelTemplate">
<StackPanel FocusVisualStyle="{x:Null}" Orientation="Horizontal" HorizontalAlignment="Left"/>
</ItemsPanelTemplate>
<Style x:Key="StackPanelListBox" BasedOn="{StaticResource ListBoxBaseStyle}" TargetType="ListBox">
<Setter Property="ItemsPanel" Value="{StaticResource StackPanelItemsPanelTemplate}"/>
<Setter Property="ItemContainerStyle" Value="{StaticResource ListBoxItemFullStyle}"/>
</Style>
</ResourceDictionary>