215 lines
12 KiB
XML
215 lines
12 KiB
XML
<ResourceDictionary
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:controls="clr-namespace:Melskin.Controls">
|
|
<ResourceDictionary.MergedDictionaries>
|
|
<ResourceDictionary Source="/Melskin;component/Themes/Animations.xaml" />
|
|
<ResourceDictionary Source="/Melskin;component/Controls/IconElement.xaml" />
|
|
</ResourceDictionary.MergedDictionaries>
|
|
<!-- 只显示当前选项 -->
|
|
<Style x:Key="ComboBoxPreviewStyle" TargetType="{x:Type ComboBox}">
|
|
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
|
<Setter Property="Background" Value="Transparent" />
|
|
<Setter Property="BorderBrush" Value="Transparent" />
|
|
<Setter Property="BorderThickness" Value="0" />
|
|
<Setter Property="Margin" Value="0" />
|
|
<Setter Property="Padding" Value="4,2" />
|
|
|
|
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
|
|
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
|
|
<Setter Property="ScrollViewer.CanContentScroll" Value="true" />
|
|
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
|
|
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type ComboBox}">
|
|
<Grid
|
|
x:Name="templateRoot"
|
|
Background="{TemplateBinding Background}"
|
|
IsHitTestVisible="False"
|
|
SnapsToDevicePixels="true">
|
|
<ContentPresenter
|
|
x:Name="contentPresenter"
|
|
Margin="{TemplateBinding Padding}"
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
Content="{TemplateBinding SelectionBoxItem}"
|
|
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
|
|
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
|
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
|
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
|
</Grid>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
|
|
</Style>
|
|
|
|
<Style x:Key="FlattenComboBoxToggleButtonStyle" TargetType="{x:Type ToggleButton}">
|
|
<Setter Property="OverridesDefaultStyle" Value="true" />
|
|
<Setter Property="IsTabStop" Value="false" />
|
|
<Setter Property="Focusable" Value="false" />
|
|
<Setter Property="ClickMode" Value="Press" />
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
|
<Border
|
|
x:Name="border"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="0"
|
|
SnapsToDevicePixels="true">
|
|
<!-- 下拉箭头 -->
|
|
<Border
|
|
x:Name="splitBorder"
|
|
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
|
|
Margin="0"
|
|
HorizontalAlignment="Right"
|
|
BorderBrush="Transparent"
|
|
BorderThickness="1"
|
|
SnapsToDevicePixels="true">
|
|
<controls:IconElement
|
|
x:Name="arrow"
|
|
Foreground="{DynamicResource TextPrimaryBrush}"
|
|
RenderTransformOrigin="0.5,0.5"
|
|
SnapsToDevicePixels="false"
|
|
Symbol="KeyboardArrowDown">
|
|
<controls:IconElement.RenderTransform>
|
|
<RotateTransform Angle="0" />
|
|
</controls:IconElement.RenderTransform>
|
|
</controls:IconElement>
|
|
</Border>
|
|
</Border>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="IsMouseOver" Value="true" />
|
|
<!-- 缩减阴影,下压效果 -->
|
|
<Trigger Property="IsPressed" Value="true" />
|
|
<Trigger Property="IsChecked" Value="True">
|
|
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource BorderGradientBrush}" />
|
|
<Trigger.EnterActions>
|
|
<BeginStoryboard Storyboard="{StaticResource ExpandRotateStoryboard}" />
|
|
</Trigger.EnterActions>
|
|
<Trigger.ExitActions>
|
|
<BeginStoryboard Storyboard="{StaticResource CollapseRotateStoryboard}" />
|
|
</Trigger.ExitActions>
|
|
</Trigger>
|
|
<!-- 按钮禁用效果 -->
|
|
<Trigger Property="IsEnabled" Value="false">
|
|
<Setter TargetName="arrow" Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
|
<Setter TargetName="border" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
|
</Trigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
<!-- 默认样式 -->
|
|
<ControlTemplate x:Key="FlattenComboBoxTemplate" TargetType="{x:Type ComboBox}">
|
|
<Grid x:Name="templateRoot" SnapsToDevicePixels="true">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*" />
|
|
<ColumnDefinition Width="0" MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
|
|
</Grid.ColumnDefinitions>
|
|
<Popup
|
|
x:Name="PART_Popup"
|
|
Grid.ColumnSpan="2"
|
|
Margin="-8"
|
|
AllowsTransparency="true"
|
|
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
|
Placement="Bottom"
|
|
PopupAnimation="Slide"
|
|
VerticalOffset="4">
|
|
<Border
|
|
x:Name="dropDownBorder"
|
|
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
|
|
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
|
Margin="8"
|
|
Background="{DynamicResource BackgroundLayoutBrush}"
|
|
BorderBrush="{DynamicResource BorderNormalBrush}"
|
|
BorderThickness="1"
|
|
CornerRadius="4">
|
|
<ScrollViewer x:Name="DropDownScrollViewer" Margin="4,3">
|
|
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
|
|
<Canvas
|
|
x:Name="canvas"
|
|
Width="0"
|
|
Height="0"
|
|
HorizontalAlignment="Left"
|
|
VerticalAlignment="Top">
|
|
<Rectangle
|
|
x:Name="opaqueRect"
|
|
Width="{Binding ActualWidth, ElementName=dropDownBorder}"
|
|
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
|
|
Fill="{Binding Background, ElementName=dropDownBorder}" />
|
|
</Canvas>
|
|
<ItemsPresenter
|
|
x:Name="ItemsPresenter"
|
|
KeyboardNavigation.DirectionalNavigation="Contained"
|
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
|
</Grid>
|
|
</ScrollViewer>
|
|
</Border>
|
|
|
|
</Popup>
|
|
<ToggleButton
|
|
x:Name="toggleButton"
|
|
Grid.Column="0"
|
|
Grid.ColumnSpan="2"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
|
Style="{StaticResource FlattenComboBoxToggleButtonStyle}" />
|
|
<ContentPresenter
|
|
x:Name="contentPresenter"
|
|
Grid.Column="0"
|
|
Margin="{TemplateBinding Padding}"
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
Content="{TemplateBinding SelectionBoxItem}"
|
|
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
|
|
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
|
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
|
|
IsHitTestVisible="false"
|
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
|
</Grid>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="true">
|
|
<Setter TargetName="dropDownBorder" Property="Effect" Value="{DynamicResource PopupShadow}" />
|
|
</Trigger>
|
|
<Trigger Property="HasItems" Value="false">
|
|
<Setter TargetName="dropDownBorder" Property="Height" Value="95" />
|
|
</Trigger>
|
|
<MultiTrigger>
|
|
<MultiTrigger.Conditions>
|
|
<Condition Property="IsGrouping" Value="true" />
|
|
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false" />
|
|
</MultiTrigger.Conditions>
|
|
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
|
|
</MultiTrigger>
|
|
<Trigger SourceName="DropDownScrollViewer" Property="ScrollViewer.CanContentScroll" Value="false">
|
|
<Setter TargetName="opaqueRect" Property="Canvas.Top" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}" />
|
|
<Setter TargetName="opaqueRect" Property="Canvas.Left" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}" />
|
|
</Trigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
|
|
<Style x:Key="FlattenComboBoxStyle" TargetType="{x:Type ComboBox}">
|
|
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
|
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
|
|
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
|
<Setter Property="BorderThickness" Value="0" />
|
|
<Setter Property="Margin" Value="0" />
|
|
<Setter Property="Padding" Value="4,2" />
|
|
|
|
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
|
|
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
|
|
<Setter Property="ScrollViewer.CanContentScroll" Value="true" />
|
|
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
|
|
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
|
<Setter Property="Template" Value="{StaticResource FlattenComboBoxTemplate}" />
|
|
|
|
</Style>
|
|
</ResourceDictionary> |