Files
ShrlAlgoToolkit/NeuWPF/NeoUI/Controls/ComboBoxStyle.xaml

589 lines
31 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2025-08-20 12:10:35 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:assists="clr-namespace:NeoUI.Assists"
xmlns:svd="clr-namespace:NeoUI.Controls.Decorations">
2025-07-31 20:12:24 +08:00
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="FlattenTextBox.xaml" />
</ResourceDictionary.MergedDictionaries>
2025-07-31 20:12:01 +08:00
<!-- 按钮高亮 -->
2025-07-11 09:20:23 +08:00
<Storyboard x:Key="Button.FocusEffect">
2025-07-31 20:12:01 +08:00
<DoubleAnimation
Storyboard.TargetName="border"
Storyboard.TargetProperty="Intensity"
2025-08-20 12:10:35 +08:00
To="0.8"
Duration="0:0:0.2" />
2025-07-31 20:12:01 +08:00
<BooleanAnimationUsingKeyFrames
Storyboard.TargetName="border"
2025-08-20 12:10:35 +08:00
Storyboard.TargetProperty="ShaderEnabled"
Duration="0">
2025-07-31 20:12:01 +08:00
<DiscreteBooleanKeyFrame KeyTime="0" Value="True" />
2025-07-11 09:20:23 +08:00
</BooleanAnimationUsingKeyFrames>
</Storyboard>
2025-07-31 20:12:01 +08:00
<!-- 按钮取消高亮 -->
2025-07-11 09:20:23 +08:00
<Storyboard x:Key="Button.LeaveEffect">
2025-07-31 20:12:01 +08:00
<DoubleAnimation
Storyboard.TargetName="border"
Storyboard.TargetProperty="Intensity"
2025-08-20 12:10:35 +08:00
To="0"
Duration="0:0:0.2" />
2025-07-31 20:12:01 +08:00
<BooleanAnimationUsingKeyFrames
Storyboard.TargetName="border"
2025-08-20 12:10:35 +08:00
Storyboard.TargetProperty="ShaderEnabled"
Duration="0:0:0.2">
2025-07-31 20:12:01 +08:00
<DiscreteBooleanKeyFrame KeyTime="0:0:0.2" Value="False" />
2025-07-11 09:20:23 +08:00
</BooleanAnimationUsingKeyFrames>
</Storyboard>
2025-07-31 20:12:01 +08:00
<!-- 按钮按下 -->
2025-07-11 09:20:23 +08:00
<Storyboard x:Key="Button.PressEffect">
2025-07-31 20:12:01 +08:00
<DoubleAnimation
Storyboard.TargetName="border"
Storyboard.TargetProperty="Intensity"
2025-08-20 12:10:35 +08:00
To="0.4"
Duration="0" />
2025-07-11 09:20:23 +08:00
</Storyboard>
2025-08-20 12:10:35 +08:00
<Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
2025-08-20 12:10:13 +08:00
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Focusable" Value="False" />
2025-07-31 20:12:01 +08:00
<Setter Property="ClickMode" Value="Press" />
2025-07-11 09:20:23 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
2025-07-31 20:12:01 +08:00
<svd:EmbossBorder
2025-08-20 12:10:35 +08:00
x:Name="border"
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
Intensity="0"
ShaderEnabled="False"
2025-08-20 12:10:35 +08:00
SnapsToDevicePixels="True">
2025-07-31 20:12:01 +08:00
<!-- 下拉箭头 -->
<Border
2025-08-20 12:10:35 +08:00
x:Name="splitBorder"
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
Margin="0"
HorizontalAlignment="Right"
2025-07-31 20:12:01 +08:00
BorderBrush="Transparent"
BorderThickness="1"
2025-08-20 12:10:35 +08:00
SnapsToDevicePixels="True">
2025-07-31 20:12:01 +08:00
<Path
2025-08-20 12:10:35 +08:00
x:Name="arrow"
2025-07-31 20:12:01 +08:00
Margin="0"
2025-08-20 12:10:35 +08:00
HorizontalAlignment="Center"
2025-07-31 20:12:01 +08:00
VerticalAlignment="Center"
2025-08-20 12:10:35 +08:00
Data="M 0,0 L 4,3 L 8,0"
Stroke="{DynamicResource TextPrimaryBrush}"
StrokeThickness="1" />
2025-07-11 09:20:23 +08:00
</Border>
</svd:EmbossBorder>
<ControlTemplate.Triggers>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsMouseOver" Value="True">
2025-08-20 12:10:35 +08:00
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource BorderGradientBrush}" />
2025-07-11 09:20:23 +08:00
<Trigger.EnterActions>
2025-08-20 12:10:35 +08:00
<BeginStoryboard x:Name="showEffectBegin" Storyboard="{StaticResource Button.FocusEffect}" />
2025-07-11 09:20:23 +08:00
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource Button.LeaveEffect}" />
</Trigger.ExitActions>
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- 缩减阴影,下压效果 -->
2025-08-20 12:10:13 +08:00
<Trigger Property="IsPressed" Value="True">
2025-07-11 09:20:23 +08:00
<Trigger.EnterActions>
2025-08-20 12:10:35 +08:00
<BeginStoryboard x:Name="pressBegin" Storyboard="{StaticResource Button.PressEffect}" />
2025-07-11 09:20:23 +08:00
</Trigger.EnterActions>
<Trigger.ExitActions>
2025-07-31 20:12:01 +08:00
<RemoveStoryboard BeginStoryboardName="pressBegin" />
2025-07-11 09:20:23 +08:00
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsChecked" Value="True">
2025-08-20 12:10:35 +08:00
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource BorderGradientBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- 按钮禁用效果 -->
2025-08-20 12:10:13 +08:00
<Trigger Property="IsEnabled" Value="False">
2025-08-20 12:10:35 +08:00
<Setter TargetName="arrow" Property="Fill" Value="{DynamicResource TextDisabledBrush}" />
<Setter TargetName="border" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-08-20 12:10:35 +08:00
<!-- 可编辑模板 -->
<ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
<Grid x:Name="templateRoot" SnapsToDevicePixels="True">
2025-07-11 09:20:23 +08:00
<Grid.ColumnDefinitions>
2025-07-31 20:12:01 +08:00
<ColumnDefinition Width="*" />
2025-08-20 12:10:35 +08:00
<ColumnDefinition Width="0" MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
2025-07-11 09:20:23 +08:00
</Grid.ColumnDefinitions>
2025-07-31 20:12:01 +08:00
<Popup
2025-08-20 12:10:35 +08:00
x:Name="PART_Popup"
2025-07-31 20:12:01 +08:00
Grid.ColumnSpan="2"
Margin="-8"
2025-08-20 12:10:35 +08:00
AllowsTransparency="True"
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
2025-07-31 20:12:01 +08:00
Placement="Bottom"
PopupAnimation="Slide"
2025-08-20 12:10:35 +08:00
VerticalOffset="4">
2025-07-31 20:12:01 +08:00
<Border
2025-08-20 12:10:35 +08:00
x:Name="dropDownBorder"
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
Margin="8"
2025-08-12 23:08:54 +08:00
Background="{DynamicResource BackgroundLayoutBrush}"
BorderBrush="{DynamicResource BorderNormalBrush}"
2025-07-31 20:12:01 +08:00
BorderThickness="1"
2025-08-20 12:10:35 +08:00
CornerRadius="4">
<ScrollViewer x:Name="DropDownScrollViewer" Margin="4,3">
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
2025-07-31 20:12:01 +08:00
<Canvas
2025-08-20 12:10:35 +08:00
x:Name="canvas"
Width="0"
2025-07-31 20:12:01 +08:00
Height="0"
HorizontalAlignment="Left"
2025-08-20 12:10:35 +08:00
VerticalAlignment="Top">
2025-07-31 20:12:01 +08:00
<Rectangle
2025-08-20 12:10:35 +08:00
x:Name="opaqueRect"
2025-07-31 20:12:01 +08:00
Width="{Binding ActualWidth, ElementName=dropDownBorder}"
2025-08-20 12:10:35 +08:00
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
Fill="{Binding Background, ElementName=dropDownBorder}" />
2025-07-11 09:20:23 +08:00
</Canvas>
2025-07-31 20:12:01 +08:00
<ItemsPresenter
2025-08-20 12:10:35 +08:00
x:Name="ItemsPresenter"
2025-07-31 20:12:01 +08:00
KeyboardNavigation.DirectionalNavigation="Contained"
2025-08-20 12:10:35 +08:00
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2025-07-11 09:20:23 +08:00
</Grid>
</ScrollViewer>
</Border>
</Popup>
2025-07-31 20:12:01 +08:00
<ToggleButton
2025-08-20 12:10:35 +08:00
x:Name="toggleButton"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="-4"
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
2025-08-20 12:10:35 +08:00
Style="{StaticResource ComboBoxToggleButton}" />
2025-07-31 20:12:01 +08:00
<Border
2025-08-20 12:10:35 +08:00
x:Name="border"
2025-07-31 20:12:01 +08:00
Grid.Column="0"
2025-08-20 12:10:35 +08:00
Margin="{TemplateBinding BorderThickness}">
2025-07-31 20:12:01 +08:00
<TextBox
2025-08-20 12:10:35 +08:00
x:Name="PART_EditableTextBox"
2025-07-31 20:12:01 +08:00
Margin="{TemplateBinding Padding}"
Padding="6,4"
2025-08-20 12:10:35 +08:00
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
2025-07-31 20:12:01 +08:00
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
2025-08-20 12:10:35 +08:00
IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource FlattenTextBox}" />
2025-07-11 09:20:23 +08:00
</Border>
2025-08-20 12:10:35 +08:00
<TextBlock
Padding="6,4"
x:Name="Placeholder"
Margin="{TemplateBinding Padding}"
VerticalAlignment="Center"
Foreground="{DynamicResource TextSecondaryBrush}"
IsHitTestVisible="False"
Text="{Binding Path=(assists:SelectorAssist.Placeholder), RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ComboBox}}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType=ComboBox}}" Value="{x:Null}">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsEnabled" Value="False">
2025-08-20 12:10:35 +08:00
<Setter TargetName="border" Property="Opacity" Value="0.56" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsKeyboardFocusWithin" Value="True" />
2025-08-20 12:10:35 +08:00
<Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="True">
<Setter TargetName="dropDownBorder" Property="Effect" Value="{DynamicResource PopupShadow}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="HasItems" Value="False">
2025-08-20 12:10:35 +08:00
<Setter TargetName="dropDownBorder" Property="Height" Value="95" />
2025-07-11 09:20:23 +08:00
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
2025-08-20 12:10:13 +08:00
<Condition Property="IsGrouping" Value="True" />
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="False" />
2025-07-11 09:20:23 +08:00
</MultiTrigger.Conditions>
2025-08-20 12:10:13 +08:00
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
2025-07-11 09:20:23 +08:00
</MultiTrigger>
2025-08-20 12:10:35 +08:00
<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}" />
2025-07-11 09:20:23 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
2025-08-20 12:10:35 +08:00
<!-- 默认控件模板 -->
<ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}">
<Grid x:Name="templateRoot" SnapsToDevicePixels="True">
2025-07-11 09:20:23 +08:00
<Grid.ColumnDefinitions>
2025-07-31 20:12:01 +08:00
<ColumnDefinition Width="*" />
2025-08-20 12:10:35 +08:00
<ColumnDefinition Width="0" MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
2025-07-11 09:20:23 +08:00
</Grid.ColumnDefinitions>
2025-07-31 20:12:01 +08:00
<Popup
2025-08-20 12:10:35 +08:00
x:Name="PART_Popup"
2025-07-31 20:12:01 +08:00
Grid.ColumnSpan="2"
Margin="-8"
2025-08-20 12:10:35 +08:00
AllowsTransparency="True"
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
2025-07-31 20:12:01 +08:00
Placement="Bottom"
PopupAnimation="Slide"
2025-08-20 12:10:35 +08:00
VerticalOffset="4">
2025-07-31 20:12:01 +08:00
<Border
2025-08-20 12:10:35 +08:00
x:Name="dropDownBorder"
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
Margin="8"
2025-08-12 23:08:54 +08:00
Background="{DynamicResource BackgroundLayoutBrush}"
BorderBrush="{DynamicResource BorderNormalBrush}"
2025-07-31 20:12:01 +08:00
BorderThickness="1"
2025-08-20 12:10:35 +08:00
CornerRadius="4">
<ScrollViewer x:Name="DropDownScrollViewer" Margin="4,3">
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
2025-07-31 20:12:01 +08:00
<Canvas
2025-08-20 12:10:35 +08:00
x:Name="canvas"
Width="0"
2025-07-31 20:12:01 +08:00
Height="0"
HorizontalAlignment="Left"
2025-08-20 12:10:35 +08:00
VerticalAlignment="Top">
2025-07-31 20:12:01 +08:00
<Rectangle
2025-08-20 12:10:35 +08:00
x:Name="opaqueRect"
2025-07-31 20:12:01 +08:00
Width="{Binding ActualWidth, ElementName=dropDownBorder}"
2025-08-20 12:10:35 +08:00
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
Fill="{Binding Background, ElementName=dropDownBorder}" />
2025-07-11 09:20:23 +08:00
</Canvas>
2025-07-31 20:12:01 +08:00
<ItemsPresenter
2025-08-20 12:10:35 +08:00
x:Name="ItemsPresenter"
2025-07-31 20:12:01 +08:00
KeyboardNavigation.DirectionalNavigation="Contained"
2025-08-20 12:10:35 +08:00
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2025-07-11 09:20:23 +08:00
</Grid>
</ScrollViewer>
</Border>
</Popup>
2025-07-31 20:12:01 +08:00
<ToggleButton
2025-08-20 12:10:35 +08:00
x:Name="toggleButton"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="-4"
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
2025-08-20 12:10:35 +08:00
Style="{StaticResource ComboBoxToggleButton}" />
<TextBlock
x:Name="Placeholder"
Margin="{TemplateBinding Padding}"
VerticalAlignment="Center"
Foreground="{DynamicResource TextSecondaryBrush}"
IsHitTestVisible="False"
Text="{Binding Path=(assists:SelectorAssist.Placeholder), RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ComboBox}}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType=ComboBox}}" Value="{x:Null}">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
2025-07-31 20:12:01 +08:00
<ContentPresenter
2025-08-20 12:10:35 +08:00
x:Name="contentPresenter"
Grid.Column="0"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2025-07-31 20:12:01 +08:00
Content="{TemplateBinding SelectionBoxItem}"
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
2025-08-20 12:10:13 +08:00
IsHitTestVisible="False"
2025-08-20 12:10:35 +08:00
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
2025-08-20 12:10:35 +08:00
<Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="True">
<Setter TargetName="dropDownBorder" Property="Effect" Value="{DynamicResource PopupShadow}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="HasItems" Value="False">
2025-08-20 12:10:35 +08:00
<Setter TargetName="dropDownBorder" Property="Height" Value="95" />
2025-07-11 09:20:23 +08:00
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
2025-08-20 12:10:13 +08:00
<Condition Property="IsGrouping" Value="True" />
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="False" />
2025-07-11 09:20:23 +08:00
</MultiTrigger.Conditions>
2025-08-20 12:10:13 +08:00
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
2025-07-11 09:20:23 +08:00
</MultiTrigger>
2025-08-20 12:10:35 +08:00
<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}" />
2025-07-11 09:20:23 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
2025-08-20 12:10:35 +08:00
<!-- 默认ComboBox样式 -->
<Style x:Key="ComboBoxDefault" TargetType="{x:Type ComboBox}">
2025-07-31 20:12:24 +08:00
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
2025-08-12 23:08:54 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
2025-08-20 12:10:35 +08:00
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="assists:SelectorAssist.Placeholder" Value="请选择..." />
2025-07-31 20:12:01 +08:00
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Margin" Value="4" />
<Setter Property="Padding" Value="10,8" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
2025-08-20 12:10:13 +08:00
<Setter Property="ScrollViewer.CanContentScroll" Value="True" />
2025-07-31 20:12:01 +08:00
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<Setter Property="Template" Value="{StaticResource ComboBoxTemplate}" />
2025-07-11 09:20:23 +08:00
<Style.Triggers>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsEditable" Value="True">
<Setter Property="IsTabStop" Value="False" />
2025-07-31 20:12:01 +08:00
<Setter Property="Padding" Value="3" />
<Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}" />
2025-07-11 09:20:23 +08:00
</Trigger>
</Style.Triggers>
</Style>
2025-07-31 20:12:01 +08:00
<!-- 默认下拉样式 -->
<Style BasedOn="{StaticResource ComboBoxDefault}" TargetType="{x:Type ComboBox}" />
2025-07-11 09:20:23 +08:00
2025-07-31 20:12:01 +08:00
<!-- 内容样式 -->
2025-07-11 09:20:23 +08:00
<Style TargetType="{x:Type ComboBoxItem}">
2025-07-31 20:12:01 +08:00
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Padding" Value="12,4,8,4" />
<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" />
2025-07-31 20:12:24 +08:00
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Grid Margin="0,1">
2025-07-31 20:12:01 +08:00
<Border
2025-08-20 12:10:35 +08:00
x:Name="Bd"
Padding="{TemplateBinding Padding}"
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
2025-07-11 09:20:23 +08:00
BorderThickness="{TemplateBinding BorderThickness}"
2025-07-31 20:12:01 +08:00
CornerRadius="4"
2025-08-20 12:10:35 +08:00
SnapsToDevicePixels="True">
2025-07-31 20:12:01 +08:00
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
2025-08-20 12:10:35 +08:00
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2025-07-11 09:20:23 +08:00
</Border>
2025-08-12 23:08:54 +08:00
<!-- 选中标记 -->
2025-07-31 20:12:01 +08:00
<Border
2025-08-20 12:10:35 +08:00
x:Name="box"
2025-07-31 20:12:01 +08:00
CornerRadius="4"
2025-08-20 12:10:35 +08:00
Visibility="Hidden">
2025-07-31 20:12:01 +08:00
<Border
2025-08-20 12:10:35 +08:00
Width="4"
2025-07-31 20:12:01 +08:00
Margin="2,4"
2025-08-20 12:10:35 +08:00
HorizontalAlignment="Left"
Background="{DynamicResource PrimaryNormalBrush}"
CornerRadius="2" />
2025-07-11 09:20:23 +08:00
</Border>
</Grid>
2025-07-31 20:12:01 +08:00
2025-07-11 09:20:23 +08:00
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
2025-08-20 12:10:35 +08:00
<Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsSelected" Value="True">
2025-08-20 12:10:35 +08:00
<Setter TargetName="box" Property="Visibility" Value="Visible" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
2025-08-20 12:10:35 +08:00
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-08-12 23:08:54 +08:00
<!--<Trigger Property="IsKeyboardFocused" Value="True">
<Setter Property="BorderBrush" TargetName="Bd"
2025-08-20 12:10:35 +08:00
Value="{StaticResource AdditionalBlueColor}"/>
2025-08-12 23:08:54 +08:00
</Trigger>-->
2025-07-11 09:20:23 +08:00
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-07-31 20:12:01 +08:00
<!-- 工具栏下拉Toggle -->
2025-08-20 12:10:35 +08:00
<Style x:Key="ToolbarComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
2025-08-20 12:10:13 +08:00
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Focusable" Value="False" />
2025-07-31 20:12:01 +08:00
<Setter Property="ClickMode" Value="Press" />
2025-07-11 09:20:23 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
2025-07-31 20:12:01 +08:00
<Border
2025-08-20 12:10:35 +08:00
x:Name="border"
Margin="4"
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
2025-08-20 12:10:35 +08:00
SnapsToDevicePixels="True">
2025-07-31 20:12:01 +08:00
<!-- 下拉箭头 -->
<Border
2025-08-20 12:10:35 +08:00
x:Name="splitBorder"
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
Margin="0"
HorizontalAlignment="Right"
2025-07-31 20:12:01 +08:00
BorderBrush="Transparent"
BorderThickness="1"
2025-08-20 12:10:35 +08:00
SnapsToDevicePixels="True">
2025-07-31 20:12:01 +08:00
<Path
2025-08-20 12:10:35 +08:00
x:Name="arrow"
2025-07-31 20:12:01 +08:00
Margin="0"
2025-08-20 12:10:35 +08:00
HorizontalAlignment="Center"
2025-07-31 20:12:01 +08:00
VerticalAlignment="Center"
2025-08-20 12:10:35 +08:00
Data="M 0,0 L 4,3 L 8,0"
Stroke="{DynamicResource TextPrimaryBrush}"
StrokeThickness="1" />
2025-07-11 09:20:23 +08:00
</Border>
</Border>
<ControlTemplate.Triggers>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsMouseOver" Value="True">
2025-08-20 12:10:35 +08:00
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- 下压效果 -->
2025-08-20 12:10:13 +08:00
<Trigger Property="IsPressed" Value="True">
2025-08-20 12:10:35 +08:00
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsChecked" Value="True">
2025-08-20 12:10:35 +08:00
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- 按钮禁用效果 -->
2025-08-20 12:10:13 +08:00
<Trigger Property="IsEnabled" Value="False">
2025-08-20 12:10:35 +08:00
<Setter TargetName="arrow" Property="Fill" Value="{DynamicResource TextDisabledBrush}" />
<Setter TargetName="border" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-07-31 20:12:01 +08:00
<!-- 工具栏默认样式 -->
2025-08-20 12:10:35 +08:00
<ControlTemplate x:Key="ToolBarComboBoxTemplate" TargetType="{x:Type ComboBox}">
<Grid x:Name="templateRoot" SnapsToDevicePixels="True">
2025-07-11 09:20:23 +08:00
<Grid.ColumnDefinitions>
2025-07-31 20:12:01 +08:00
<ColumnDefinition Width="*" />
2025-08-20 12:10:35 +08:00
<ColumnDefinition Width="0" MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
2025-07-11 09:20:23 +08:00
</Grid.ColumnDefinitions>
2025-07-31 20:12:01 +08:00
<Popup
2025-08-20 12:10:35 +08:00
x:Name="PART_Popup"
2025-07-31 20:12:01 +08:00
Grid.ColumnSpan="2"
Margin="-8"
2025-08-20 12:10:35 +08:00
AllowsTransparency="True"
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
2025-07-31 20:12:01 +08:00
Placement="Bottom"
PopupAnimation="Slide"
2025-08-20 12:10:35 +08:00
VerticalOffset="4">
2025-07-31 20:12:01 +08:00
<Border
2025-08-20 12:10:35 +08:00
x:Name="dropDownBorder"
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
Margin="8"
2025-08-12 23:08:54 +08:00
Background="{DynamicResource BackgroundLayoutBrush}"
BorderBrush="{DynamicResource BorderNormalBrush}"
2025-07-31 20:12:01 +08:00
BorderThickness="1"
2025-08-20 12:10:35 +08:00
CornerRadius="4">
<ScrollViewer x:Name="DropDownScrollViewer" Margin="4,3">
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
2025-07-31 20:12:01 +08:00
<Canvas
2025-08-20 12:10:35 +08:00
x:Name="canvas"
Width="0"
2025-07-31 20:12:01 +08:00
Height="0"
HorizontalAlignment="Left"
2025-08-20 12:10:35 +08:00
VerticalAlignment="Top">
2025-07-31 20:12:01 +08:00
<Rectangle
2025-08-20 12:10:35 +08:00
x:Name="opaqueRect"
2025-07-31 20:12:01 +08:00
Width="{Binding ActualWidth, ElementName=dropDownBorder}"
2025-08-20 12:10:35 +08:00
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
Fill="{Binding Background, ElementName=dropDownBorder}" />
2025-07-11 09:20:23 +08:00
</Canvas>
2025-07-31 20:12:01 +08:00
<ItemsPresenter
2025-08-20 12:10:35 +08:00
x:Name="ItemsPresenter"
2025-07-31 20:12:01 +08:00
KeyboardNavigation.DirectionalNavigation="Contained"
2025-08-20 12:10:35 +08:00
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2025-07-11 09:20:23 +08:00
</Grid>
</ScrollViewer>
</Border>
</Popup>
2025-07-31 20:12:01 +08:00
<ToggleButton
2025-08-20 12:10:35 +08:00
x:Name="toggleButton"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="-4"
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
2025-08-20 12:10:35 +08:00
Style="{StaticResource ToolbarComboBoxToggleButton}" />
2025-07-31 20:12:01 +08:00
<ContentPresenter
2025-08-20 12:10:35 +08:00
x:Name="contentPresenter"
Grid.Column="0"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2025-07-31 20:12:01 +08:00
Content="{TemplateBinding SelectionBoxItem}"
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
2025-08-20 12:10:13 +08:00
IsHitTestVisible="False"
2025-08-20 12:10:35 +08:00
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
2025-08-20 12:10:35 +08:00
<Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="True">
<Setter TargetName="dropDownBorder" Property="Effect" Value="{DynamicResource PopupShadow}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="HasItems" Value="False">
2025-08-20 12:10:35 +08:00
<Setter TargetName="dropDownBorder" Property="Height" Value="95" />
2025-07-11 09:20:23 +08:00
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
2025-08-20 12:10:13 +08:00
<Condition Property="IsGrouping" Value="True" />
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="False" />
2025-07-11 09:20:23 +08:00
</MultiTrigger.Conditions>
2025-08-20 12:10:13 +08:00
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
2025-07-11 09:20:23 +08:00
</MultiTrigger>
2025-08-20 12:10:35 +08:00
<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}" />
2025-07-11 09:20:23 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
2025-07-31 20:12:01 +08:00
<!-- 工具栏下拉样式 -->
<Style
2025-08-20 12:10:35 +08:00
x:Key="{x:Static ToolBar.ComboBoxStyleKey}"
2025-07-31 20:12:01 +08:00
BasedOn="{StaticResource ComboBoxDefault}"
2025-08-20 12:10:35 +08:00
TargetType="{x:Type ComboBox}">
2025-07-31 20:12:01 +08:00
<Setter Property="Margin" Value="2" />
<Setter Property="Padding" Value="4,2" />
<Setter Property="Template" Value="{StaticResource ToolBarComboBoxTemplate}" />
2025-07-11 09:20:23 +08:00
</Style>
</ResourceDictionary>