339 lines
24 KiB
XML
339 lines
24 KiB
XML
<ResourceDictionary
|
||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||
xmlns:controls="clr-namespace:WPFluent.Controls"
|
||
xmlns:converters="clr-namespace:WPFluent.Converters"
|
||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||
<ResourceDictionary.MergedDictionaries>
|
||
<!--<ResourceDictionary Source="pack://application:,,,/WPFluent;component/Resources/Variables.xaml" />-->
|
||
<ResourceDictionary Source="pack://application:,,,/WPFluent;component/Controls/ComboBox/ComboBox.xaml" />
|
||
</ResourceDictionary.MergedDictionaries>
|
||
<converters:BooleanToVisConverter x:Key="BooleanToVisConverter" />
|
||
<Style TargetType="{x:Type controls:ComboBoxEx}" x:Key="DefaultComboBoxExStyle">
|
||
<Style.Triggers>
|
||
<Trigger Property="HeaderPlacement" Value="Left">
|
||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||
</Trigger>
|
||
<Trigger Property="HeaderPlacement" Value="Right">
|
||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||
</Trigger>
|
||
</Style.Triggers>
|
||
<!-- Universal WPF UI focus -->
|
||
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
|
||
<!-- Universal WPF UI focus -->
|
||
<!-- Universal WPF UI ContextMenu -->
|
||
<Setter Property="ContextMenu" Value="{DynamicResource DefaultControlContextMenu}" />
|
||
<!-- Universal WPF UI ContextMenu -->
|
||
<Setter Property="Background" Value="{DynamicResource ControlFillColorDefaultBrush}" />
|
||
<Setter Property="Border.CornerRadius" Value="{StaticResource ControlCornerRadius}" />
|
||
<Setter Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
|
||
<Setter Property="BorderThickness" Value="{StaticResource ComboBoxBorderThemeThickness}" />
|
||
<Setter Property="FontSize" Value="{StaticResource ControlContentThemeFontSize}" />
|
||
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
|
||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||
<Setter Property="MinHeight" Value="{StaticResource TextControlThemeMinHeight}" />
|
||
<Setter Property="MinWidth" Value="{StaticResource TextControlThemeMinWidth}" />
|
||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||
<Setter Property="Padding" Value="{StaticResource ComboBoxPadding}" />
|
||
<Setter Property="Popup.Placement" Value="Bottom" />
|
||
<Setter Property="Popup.PopupAnimation" Value="Slide" />
|
||
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
|
||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
|
||
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
|
||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
|
||
<Setter Property="VerticalAlignment" Value="Center" />
|
||
<!-- WPF 不喜欢居中,动画很难看,鼠标按钮有时会立即点击。 -->
|
||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||
<Setter Property="Template">
|
||
<Setter.Value>
|
||
<ControlTemplate TargetType="{x:Type controls:ComboBoxEx}">
|
||
<DockPanel>
|
||
<!-- 标题 -->
|
||
<TextBlock
|
||
DockPanel.Dock="{TemplateBinding HeaderPlacement}"
|
||
FontSize="{TemplateBinding FontSize}"
|
||
Margin="5"
|
||
Text="{TemplateBinding Header}"
|
||
VerticalAlignment="Center"
|
||
x:Name="Header_TextBlock" />
|
||
<Grid
|
||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||
x:Name="Grid">
|
||
<!-- 强调边缘 只有IsEditable时出现 -->
|
||
<Border
|
||
BorderBrush="{DynamicResource SystemFillColorAttentionBrush}"
|
||
BorderThickness="{StaticResource ComboBoxAccentBorderThemeThickness}"
|
||
CornerRadius="{TemplateBinding Border.CornerRadius}"
|
||
Visibility="Collapsed"
|
||
x:Name="AccentBorder" />
|
||
<Border
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
CornerRadius="{TemplateBinding Border.CornerRadius}"
|
||
Grid.Row="0"
|
||
MinHeight="{TemplateBinding MinHeight}"
|
||
MinWidth="{TemplateBinding MinWidth}"
|
||
Padding="0"
|
||
x:Name="ContentBorder">
|
||
<Grid>
|
||
<!--
|
||
Chevron 位于 Presenter 上,ToggleButton 位于 Chevron 上,TextBox 位于 ToggleButton 上。
|
||
但是,TextBox 不在 Chevron 上,所以 ToggleButton 仍能工作。
|
||
后声明在上层
|
||
-->
|
||
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="*" />
|
||
<ColumnDefinition Width="Auto" />
|
||
</Grid.ColumnDefinitions>
|
||
<Grid Grid.Column="0" Margin="{TemplateBinding Padding}">
|
||
<!--#region 扩展水印-->
|
||
<TextBlock
|
||
Focusable="False"
|
||
FontSize="{TemplateBinding FontSize}"
|
||
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
||
IsHitTestVisible="False"
|
||
Padding="1,0"
|
||
Text="{TemplateBinding PlaceholderText}"
|
||
VerticalAlignment="Center"
|
||
Visibility="Collapsed"
|
||
x:Name="PlaceholderTextBlock" />
|
||
<!--#endregion-->
|
||
<ContentPresenter
|
||
Content="{TemplateBinding SelectionBoxItem}"
|
||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
|
||
IsHitTestVisible="False"
|
||
Name="PART_ContentPresenter"
|
||
TextElement.Foreground="{TemplateBinding Foreground}" />
|
||
</Grid>
|
||
<!-- 可编辑时 -->
|
||
<ToggleButton
|
||
ClickMode="Press"
|
||
Focusable="False"
|
||
Foreground="{TemplateBinding Foreground}"
|
||
Grid.Column="0"
|
||
Grid.ColumnSpan="2"
|
||
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||
Margin="0"
|
||
Name="ToggleButton"
|
||
Style="{StaticResource DefaultComboBoxToggleButtonStyle}" />
|
||
<TextBox
|
||
FontSize="{TemplateBinding FontSize}"
|
||
Foreground="{TemplateBinding Foreground}"
|
||
Grid.Column="0"
|
||
IsReadOnly="{TemplateBinding IsReadOnly}"
|
||
Margin="{TemplateBinding Padding}"
|
||
Style="{StaticResource DefaultComboBoxTextBoxStyle}"
|
||
x:Name="PART_EditableTextBox" />
|
||
<controls:SymbolIcon
|
||
FontSize="{StaticResource ComboBoxChevronSize}"
|
||
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
||
Grid.Column="1"
|
||
IsHitTestVisible="False"
|
||
Margin="{StaticResource ComboBoxChevronMargin}"
|
||
RenderTransformOrigin="0.5, 0.5"
|
||
Symbol="ChevronDown24"
|
||
VerticalAlignment="Center"
|
||
x:Name="ChevronIcon">
|
||
<controls:SymbolIcon.RenderTransform>
|
||
<RotateTransform Angle="0" />
|
||
</controls:SymbolIcon.RenderTransform>
|
||
</controls:SymbolIcon>
|
||
</Grid>
|
||
<!-- 弹出式菜单 -->
|
||
<Popup
|
||
AllowsTransparency="True"
|
||
Focusable="False"
|
||
IsOpen="{TemplateBinding IsDropDownOpen}"
|
||
MinWidth="{TemplateBinding ActualWidth}"
|
||
Placement="{TemplateBinding Popup.Placement}"
|
||
PopupAnimation="{TemplateBinding Popup.PopupAnimation}"
|
||
VerticalAlignment="Center"
|
||
VerticalOffset="1"
|
||
x:Name="PART_Popup">
|
||
<Border
|
||
Background="{DynamicResource AcrylicBackgroundFillColorDefaultBrush}"
|
||
BorderBrush="{DynamicResource SurfaceStrokeColorDefaultBrush}"
|
||
BorderThickness="1"
|
||
CornerRadius="{StaticResource PopupCornerRadius}"
|
||
Padding="0,4,0,6"
|
||
SnapsToDevicePixels="True"
|
||
x:Name="DropDownBorder">
|
||
<Grid>
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="Auto" />
|
||
<RowDefinition />
|
||
</Grid.RowDefinitions>
|
||
<Grid Margin="5,2,5,2" Visibility="{Binding ShowFilterBox, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisConverter}}">
|
||
<TextBox x:Name="PART_FilterTextBox" />
|
||
<TextBlock
|
||
FontSize="{TemplateBinding FontSize}"
|
||
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
||
IsHitTestVisible="False"
|
||
Name="FilterPlaceholderTextBlock"
|
||
Padding="14,0"
|
||
Text="{TemplateBinding FilterBoxPlaceholderText}"
|
||
VerticalAlignment="Center"
|
||
Visibility="Collapsed" />
|
||
</Grid>
|
||
<!--<controls:TextBox
|
||
x:Name="PART_FilterTextBox"
|
||
Margin="5,2,5,2"
|
||
PlaceholderText="{TemplateBinding FilterBoxPlaceholderText}"
|
||
Visibility="{Binding ShowFilterBox, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisConverter}}" />-->
|
||
<controls:DynamicScrollViewer
|
||
Grid.Row="1"
|
||
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
||
Margin="0"
|
||
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||
SnapsToDevicePixels="True"
|
||
TextElement.FontSize="{TemplateBinding FontSize}"
|
||
TextElement.FontWeight="{TemplateBinding FontWeight}"
|
||
TextElement.Foreground="{TemplateBinding Foreground}"
|
||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
|
||
<StackPanel
|
||
IsItemsHost="True"
|
||
KeyboardNavigation.DirectionalNavigation="Contained"
|
||
TextElement.FontSize="{TemplateBinding FontSize}" />
|
||
<!--<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" TextElement.FontSize="{TemplateBinding FontSize}" />-->
|
||
</controls:DynamicScrollViewer>
|
||
</Grid>
|
||
</Border>
|
||
</Popup>
|
||
</Grid>
|
||
</Border>
|
||
</Grid>
|
||
</DockPanel>
|
||
<ControlTemplate.Triggers>
|
||
<Trigger Property="IsDropDownOpen" Value="True">
|
||
<Trigger.EnterActions>
|
||
<BeginStoryboard>
|
||
<Storyboard>
|
||
<DoubleAnimation
|
||
Duration="00:00:00.167"
|
||
From="0"
|
||
Storyboard.TargetName="ChevronIcon"
|
||
Storyboard.TargetProperty="(controls:SymbolIcon.RenderTransform).(RotateTransform.Angle)"
|
||
To="180" />
|
||
<DoubleAnimation
|
||
Duration="00:00:00.167"
|
||
From="-90"
|
||
Storyboard.TargetName="DropDownBorder"
|
||
Storyboard.TargetProperty="(Border.RenderTransform).(TranslateTransform.Y)"
|
||
To="0">
|
||
<DoubleAnimation.EasingFunction>
|
||
<CircleEase EasingMode="EaseOut" />
|
||
</DoubleAnimation.EasingFunction>
|
||
</DoubleAnimation>
|
||
</Storyboard>
|
||
</BeginStoryboard>
|
||
</Trigger.EnterActions>
|
||
<Trigger.ExitActions>
|
||
<BeginStoryboard>
|
||
<Storyboard>
|
||
<DoubleAnimation
|
||
Duration="00:00:00.167"
|
||
From="180"
|
||
Storyboard.TargetName="ChevronIcon"
|
||
Storyboard.TargetProperty="(controls:SymbolIcon.RenderTransform).(RotateTransform.Angle)"
|
||
To="0" />
|
||
</Storyboard>
|
||
</BeginStoryboard>
|
||
</Trigger.ExitActions>
|
||
</Trigger>
|
||
<Trigger Property="Text" SourceName="PART_FilterTextBox" Value="">
|
||
<Setter Property="Visibility" TargetName="FilterPlaceholderTextBlock" Value="Visible" />
|
||
</Trigger>
|
||
<Trigger Property="Header" Value="{x:Null}">
|
||
<Setter Property="Margin" TargetName="Header_TextBlock" Value="0" />
|
||
<Setter Property="Visibility" TargetName="Header_TextBlock" Value="Collapsed" />
|
||
</Trigger>
|
||
<!-- 标题左右对齐时,控制最小宽度 -->
|
||
<Trigger Property="HeaderPlacement" Value="Left">
|
||
<Setter Property="MinWidth" TargetName="Grid" Value="80" />
|
||
</Trigger>
|
||
<Trigger Property="HeaderPlacement" Value="Right">
|
||
<Setter Property="MinWidth" TargetName="Grid" Value="80" />
|
||
</Trigger>
|
||
<Trigger Property="HasItems" Value="False">
|
||
<Setter Property="MinHeight" TargetName="DropDownBorder" Value="{StaticResource ComboBoxPopupMinHeight}" />
|
||
</Trigger>
|
||
<Trigger Property="Popup.AllowsTransparency" SourceName="PART_Popup" Value="False">
|
||
<Setter Property="CornerRadius" TargetName="DropDownBorder" Value="0" />
|
||
</Trigger>
|
||
<Trigger Property="IsGrouping" Value="True">
|
||
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
|
||
</Trigger>
|
||
<Trigger Property="IsEditable" Value="True">
|
||
<Setter Property="IsTabStop" Value="False" />
|
||
<Setter Property="Visibility" TargetName="PART_EditableTextBox" Value="Visible" />
|
||
<Setter Property="Visibility" TargetName="PART_ContentPresenter" Value="Hidden" />
|
||
</Trigger>
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="IsEnabled" Value="True" />
|
||
<Condition Property="IsKeyboardFocusWithin" Value="True" />
|
||
<Condition Property="IsEditable" Value="True" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlFillColorDefaultBrush}" />
|
||
<Setter Property="Visibility" TargetName="AccentBorder" Value="Visible" />
|
||
</MultiTrigger>
|
||
<!-- 可用、指针进入、键盘不聚焦 -->
|
||
<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="IsEnabled" Value="True" />
|
||
<Condition Property="IsMouseOver" Value="True" />
|
||
<Condition Property="IsKeyboardFocusWithin" Value="False" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlFillColorSecondaryBrush}" />
|
||
</MultiTrigger>
|
||
<!-- 选中项文本 -->
|
||
<!--<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="IsEditable" Value="False" />
|
||
<Condition Property="SelectedIndex" Value="-1" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter TargetName="PlaceholderTextBlock" Property="Visibility" Value="Visible" />
|
||
</MultiTrigger>-->
|
||
<!--<MultiTrigger>
|
||
<MultiTrigger.Conditions>
|
||
<Condition Property="PlaceholderEnable" Value="True" />
|
||
<Condition Property="Text" Value="" />
|
||
</MultiTrigger.Conditions>
|
||
<Setter TargetName="PlaceholderTextBlock" Property="Visibility" Value="Visible" />
|
||
</MultiTrigger>-->
|
||
|
||
<Trigger Property="Text" Value="">
|
||
<Setter Property="Visibility" TargetName="PlaceholderTextBlock" Value="Visible" />
|
||
</Trigger>
|
||
<!--<Trigger Property="SelectedItem" Value="{x:Null}">
|
||
<Setter TargetName="PlaceholderTextBlock" Property="Visibility" Value="Visible" />
|
||
</Trigger>-->
|
||
<!--<DataTrigger Binding="{Binding Path=Text, RelativeSource={RelativeSource Mode=Self}}" Value="">
|
||
<Setter TargetName="PlaceholderTextBlock" Property="Visibility" Value="Visible" />
|
||
</DataTrigger>-->
|
||
<!--<DataTrigger Binding="{Binding Path=SelectedItem, RelativeSource={RelativeSource AncestorType={x:Type etc:ComboBoxEx}}}" Value="{x:Null}">
|
||
<Setter TargetName="PlaceholderTextBlock" Property="Visibility" Value="Visible" />
|
||
</DataTrigger>-->
|
||
<Trigger Property="IsEnabled" Value="False">
|
||
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlFillColorDisabledBrush}" />
|
||
<Setter Property="BorderBrush" TargetName="ContentBorder" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
|
||
<Setter Property="Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
|
||
<!--#region Extend 水印-->
|
||
<Setter Property="Foreground" TargetName="PlaceholderTextBlock" Value="{DynamicResource TextFillColorDisabledBrush}" />
|
||
<!--#endregion-->
|
||
</Trigger>
|
||
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
</Setter.Value>
|
||
</Setter>
|
||
<Setter Property="VerticalContentAlignment" Value="Top" />
|
||
</Style>
|
||
|
||
<!--<Style BasedOn="{StaticResource DefaultComboBoxItemStyle}" TargetType="{x:Type ComboBoxItem}" />-->
|
||
<Style BasedOn="{StaticResource DefaultComboBoxExStyle}" TargetType="{x:Type controls:ComboBoxEx}" />
|
||
</ResourceDictionary> |