月更
This commit is contained in:
291
AntDesignWPF/Controls/ComboBox.xaml
Normal file
291
AntDesignWPF/Controls/ComboBox.xaml
Normal file
@@ -0,0 +1,291 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:controls="clr-namespace:AntDesignWPF.Controls"
|
||||
xmlns:helpers="clr-namespace:AntDesignWPF.Helpers"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Themes/Converters.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Themes/Animations.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Controls/Control.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Controls/Input.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="{x:Type ToggleButton}" x:Key="Ant.ComboBoxToggleButton">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<Grid
|
||||
Background="{TemplateBinding Background}"
|
||||
Opacity="0.45"
|
||||
x:Name="Root">
|
||||
<ContentPresenter
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="Content">
|
||||
<ContentPresenter.RenderTransform>
|
||||
<RotateTransform />
|
||||
</ContentPresenter.RenderTransform>
|
||||
</ContentPresenter>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualStateGroup.Transitions>
|
||||
<VisualTransition GeneratedDuration="0:0:0.3" />
|
||||
</VisualStateGroup.Transitions>
|
||||
<VisualState x:Name="Normal" />
|
||||
<VisualState x:Name="MouseOver">
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="Root"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0.65" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Pressed">
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="Root"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="1" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Disabled" />
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="CheckStates">
|
||||
<VisualStateGroup.Transitions>
|
||||
<VisualTransition GeneratedDuration="0:0:0.3" />
|
||||
</VisualStateGroup.Transitions>
|
||||
<VisualState x:Name="Checked">
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="Content"
|
||||
Storyboard.TargetProperty="RenderTransform.Angle"
|
||||
To="180" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Unchecked" />
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style
|
||||
BasedOn="{StaticResource Ant.Input}"
|
||||
TargetType="{x:Type ComboBox}"
|
||||
x:Key="Ant.ComboBox">
|
||||
<Setter Property="MaxDropDownHeight" Value="250" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ComboBox}">
|
||||
<Grid>
|
||||
<!-- Input Effect -->
|
||||
<Border
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{DynamicResource OutlineThickness}"
|
||||
CornerRadius="{TemplateBinding helpers:AntControl.CornerRadius}"
|
||||
Focusable="False"
|
||||
Margin="{Binding BorderThickness, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={StaticResource ThicknessReverseConverter}}"
|
||||
Opacity="0"
|
||||
x:Name="Effect" />
|
||||
<!-- Input -->
|
||||
<controls:AntBorder
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderStyle="{TemplateBinding helpers:AntControl.BorderStyle}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding helpers:AntControl.CornerRadius}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
UseLayoutRounding="True"
|
||||
x:Name="Border">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<!-- Prefix -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<!-- Input -->
|
||||
<ColumnDefinition Width="*" />
|
||||
<!-- Suffix -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Prefix -->
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding helpers:Input.Prefix}"
|
||||
Focusable="False"
|
||||
Grid.Column="0"
|
||||
Margin="1,0,5,0"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="Prefix" />
|
||||
<!-- Placeholder -->
|
||||
<TextBlock
|
||||
Focusable="False"
|
||||
Foreground="{TemplateBinding helpers:Input.PlaceholderBrush}"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Text="{TemplateBinding helpers:Input.Placeholder}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Visibility="Collapsed"
|
||||
x:Name="Placeholder" />
|
||||
<!-- Editable TextBox -->
|
||||
<TextBox
|
||||
Grid.Column="1"
|
||||
Style="{StaticResource Ant.EditableTextBox}"
|
||||
Visibility="Collapsed"
|
||||
x:Name="PART_EditableTextBox" />
|
||||
<!-- ContentSite -->
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding SelectionBoxItem}"
|
||||
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
|
||||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
IsHitTestVisible="False"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="ContentSite" />
|
||||
<!-- DropDownToggle -->
|
||||
<ToggleButton
|
||||
Background="Transparent"
|
||||
Focusable="False"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="2"
|
||||
HorizontalContentAlignment="Right"
|
||||
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
IsTabStop="False"
|
||||
Padding="5,0,1,0"
|
||||
Style="{StaticResource Ant.ComboBoxToggleButton}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="DropDownToggle">
|
||||
<controls:Icon Type="down" />
|
||||
</ToggleButton>
|
||||
<!-- Clear -->
|
||||
<controls:Icon
|
||||
Focusable="False"
|
||||
Grid.Column="2"
|
||||
Margin="5,0,1,0"
|
||||
Style="{StaticResource Ant.Clearable}"
|
||||
Type="close"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Visibility="Collapsed"
|
||||
helpers:Input.ClearEnabled="True"
|
||||
x:Name="Clear" />
|
||||
</Grid>
|
||||
</controls:AntBorder>
|
||||
<!-- Popup -->
|
||||
<Popup
|
||||
AllowsTransparency="True"
|
||||
Focusable="False"
|
||||
IsOpen="{TemplateBinding IsDropDownOpen}"
|
||||
Placement="Bottom"
|
||||
PopupAnimation="Slide"
|
||||
VerticalOffset="4"
|
||||
x:Name="PART_Popup">
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="{TemplateBinding helpers:AntControl.CornerRadius}"
|
||||
Margin="8"
|
||||
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||
Width="{Binding ActualWidth, Mode=OneWay, ElementName=Border}">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect
|
||||
BlurRadius="8"
|
||||
Opacity="0.15"
|
||||
ShadowDepth="0" />
|
||||
</Border.Effect>
|
||||
<ScrollViewer>
|
||||
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" />
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Popup>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="FocusStates">
|
||||
<VisualStateGroup.Transitions>
|
||||
<VisualTransition GeneratedDuration="0:0:0.3" />
|
||||
</VisualStateGroup.Transitions>
|
||||
<VisualState Storyboard="{StaticResource Ant.InputAnimating}" x:Name="Focused" />
|
||||
<VisualState x:Name="Unfocused" />
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="Content" SourceName="Prefix" Value="{x:Null}">
|
||||
<Setter Property="Visibility" TargetName="Prefix" Value="Collapsed" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEditable" Value="True">
|
||||
<Setter Property="Visibility" TargetName="ContentSite" Value="Hidden" />
|
||||
<Setter Property="Background" TargetName="DropDownToggle" Value="{x:Null}" />
|
||||
<Setter Property="Visibility" TargetName="PART_EditableTextBox" Value="Visible" />
|
||||
</Trigger>
|
||||
<!-- Fix Focused -->
|
||||
<Trigger Property="IsFocused" SourceName="PART_EditableTextBox" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource AntDesign.Brush.Primary}" />
|
||||
</Trigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding Text, Mode=OneWay, ElementName=PART_EditableTextBox}" Value="" />
|
||||
<Condition Binding="{Binding SelectedItem, Mode=OneWay, RelativeSource={RelativeSource Self}}" Value="{x:Null}" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Visibility" TargetName="Placeholder" Value="Visible" />
|
||||
</MultiDataTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="helpers:Input.Clearable" Value="True" />
|
||||
<Condition Property="Visibility" SourceName="Placeholder" Value="Collapsed" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Visibility" TargetName="Clear" Value="Visible" />
|
||||
<Setter Property="Content" TargetName="DropDownToggle" Value="" />
|
||||
</MultiTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style
|
||||
BasedOn="{StaticResource Ant.TextElement}"
|
||||
TargetType="{x:Type ComboBoxItem}"
|
||||
x:Key="Ant.ComboBoxItem">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Padding" Value="{DynamicResource ItemPadding}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.TextPrimary}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
|
||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.FillTertiary}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="FontWeight" Value="SemiBold" />
|
||||
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.BackgroundContainer}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.TextQuaternary}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style BasedOn="{StaticResource Ant.ComboBoxItem}" TargetType="ComboBoxItem" />
|
||||
|
||||
<Style BasedOn="{StaticResource Ant.ComboBox}" TargetType="ComboBox" />
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user