整理
This commit is contained in:
@@ -1,48 +1,49 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:svd="clr-namespace:NeumUI.Controls.Decorations"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:assists="clr-namespace:NeoUI.Assists"
|
||||
xmlns:svd="clr-namespace:NeoUI.Controls.Decorations">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="FlattenTextBox.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<!-- 按钮高亮 -->
|
||||
<Storyboard x:Key="Button.FocusEffect">
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.2"
|
||||
Storyboard.TargetName="border"
|
||||
Storyboard.TargetProperty="Intensity"
|
||||
To="0.8" />
|
||||
To="0.8"
|
||||
Duration="0:0:0.2" />
|
||||
<BooleanAnimationUsingKeyFrames
|
||||
Duration="0"
|
||||
Storyboard.TargetName="border"
|
||||
Storyboard.TargetProperty="ShaderEnabled">
|
||||
Storyboard.TargetProperty="ShaderEnabled"
|
||||
Duration="0">
|
||||
<DiscreteBooleanKeyFrame KeyTime="0" Value="True" />
|
||||
</BooleanAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<!-- 按钮取消高亮 -->
|
||||
<Storyboard x:Key="Button.LeaveEffect">
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.2"
|
||||
Storyboard.TargetName="border"
|
||||
Storyboard.TargetProperty="Intensity"
|
||||
To="0" />
|
||||
To="0"
|
||||
Duration="0:0:0.2" />
|
||||
<BooleanAnimationUsingKeyFrames
|
||||
Duration="0:0:0.2"
|
||||
Storyboard.TargetName="border"
|
||||
Storyboard.TargetProperty="ShaderEnabled">
|
||||
Storyboard.TargetProperty="ShaderEnabled"
|
||||
Duration="0:0:0.2">
|
||||
<DiscreteBooleanKeyFrame KeyTime="0:0:0.2" Value="False" />
|
||||
</BooleanAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<!-- 按钮按下 -->
|
||||
<Storyboard x:Key="Button.PressEffect">
|
||||
<DoubleAnimation
|
||||
Duration="0"
|
||||
Storyboard.TargetName="border"
|
||||
Storyboard.TargetProperty="Intensity"
|
||||
To="0.4" />
|
||||
To="0.4"
|
||||
Duration="0" />
|
||||
</Storyboard>
|
||||
|
||||
<Style TargetType="{x:Type ToggleButton}" x:Key="ComboBoxToggleButton">
|
||||
<Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
@@ -51,38 +52,38 @@
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<svd:EmbossBorder
|
||||
x:Name="border"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4"
|
||||
Intensity="0"
|
||||
ShaderEnabled="False"
|
||||
SnapsToDevicePixels="True"
|
||||
x:Name="border">
|
||||
SnapsToDevicePixels="True">
|
||||
<!-- 下拉箭头 -->
|
||||
<Border
|
||||
x:Name="splitBorder"
|
||||
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
|
||||
Margin="0"
|
||||
HorizontalAlignment="Right"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="1"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0"
|
||||
SnapsToDevicePixels="True"
|
||||
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
|
||||
x:Name="splitBorder">
|
||||
SnapsToDevicePixels="True">
|
||||
<Path
|
||||
Data="M 0,0 L 4,3 L 8,0"
|
||||
HorizontalAlignment="Center"
|
||||
x:Name="arrow"
|
||||
Margin="0"
|
||||
Stroke="{DynamicResource TextPrimaryBrush}"
|
||||
StrokeThickness="1"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
x:Name="arrow" />
|
||||
Data="M 0,0 L 4,3 L 8,0"
|
||||
Stroke="{DynamicResource TextPrimaryBrush}"
|
||||
StrokeThickness="1" />
|
||||
</Border>
|
||||
</svd:EmbossBorder>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource BorderGradientBrush}" />
|
||||
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource BorderGradientBrush}" />
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource Button.FocusEffect}" x:Name="showEffectBegin" />
|
||||
<BeginStoryboard x:Name="showEffectBegin" Storyboard="{StaticResource Button.FocusEffect}" />
|
||||
</Trigger.EnterActions>
|
||||
<Trigger.ExitActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource Button.LeaveEffect}" />
|
||||
@@ -91,19 +92,19 @@
|
||||
<!-- 缩减阴影,下压效果 -->
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource Button.PressEffect}" x:Name="pressBegin" />
|
||||
<BeginStoryboard x:Name="pressBegin" Storyboard="{StaticResource Button.PressEffect}" />
|
||||
</Trigger.EnterActions>
|
||||
<Trigger.ExitActions>
|
||||
<RemoveStoryboard BeginStoryboardName="pressBegin" />
|
||||
</Trigger.ExitActions>
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource BorderGradientBrush}" />
|
||||
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource BorderGradientBrush}" />
|
||||
</Trigger>
|
||||
<!-- 按钮禁用效果 -->
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Fill" TargetName="arrow" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter Property="Background" TargetName="border" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter TargetName="arrow" Property="Fill" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter TargetName="border" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
@@ -111,88 +112,108 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 可编辑样式 -->
|
||||
<ControlTemplate TargetType="{x:Type ComboBox}" x:Key="ComboBoxEditableTemplate">
|
||||
<Grid SnapsToDevicePixels="True" x:Name="templateRoot">
|
||||
<!-- 可编辑模板 -->
|
||||
<ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
|
||||
<Grid x:Name="templateRoot" SnapsToDevicePixels="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0" />
|
||||
<ColumnDefinition Width="0" MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Popup
|
||||
AllowsTransparency="True"
|
||||
x:Name="PART_Popup"
|
||||
Grid.ColumnSpan="2"
|
||||
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Margin="-8"
|
||||
AllowsTransparency="True"
|
||||
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Placement="Bottom"
|
||||
PopupAnimation="Slide"
|
||||
VerticalOffset="4"
|
||||
x:Name="PART_Popup">
|
||||
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"
|
||||
Margin="8"
|
||||
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
|
||||
x:Name="dropDownBorder">
|
||||
<ScrollViewer Margin="4,3" x:Name="DropDownScrollViewer">
|
||||
<Grid RenderOptions.ClearTypeHint="Enabled" x:Name="grid">
|
||||
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"
|
||||
Width="0"
|
||||
x:Name="canvas">
|
||||
VerticalAlignment="Top">
|
||||
<Rectangle
|
||||
Fill="{Binding Background, ElementName=dropDownBorder}"
|
||||
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
|
||||
x:Name="opaqueRect"
|
||||
Width="{Binding ActualWidth, ElementName=dropDownBorder}"
|
||||
x:Name="opaqueRect" />
|
||||
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
|
||||
Fill="{Binding Background, ElementName=dropDownBorder}" />
|
||||
</Canvas>
|
||||
<ItemsPresenter
|
||||
x:Name="ItemsPresenter"
|
||||
KeyboardNavigation.DirectionalNavigation="Contained"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
x:Name="ItemsPresenter" />
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
|
||||
</Popup>
|
||||
<ToggleButton
|
||||
x:Name="toggleButton"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="-4"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Margin="-4"
|
||||
Style="{StaticResource ComboBoxToggleButton}"
|
||||
x:Name="toggleButton" />
|
||||
Style="{StaticResource ComboBoxToggleButton}" />
|
||||
|
||||
<Border
|
||||
x:Name="border"
|
||||
Grid.Column="0"
|
||||
Margin="{TemplateBinding BorderThickness}"
|
||||
x:Name="border">
|
||||
Margin="{TemplateBinding BorderThickness}">
|
||||
<TextBox
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
x:Name="PART_EditableTextBox"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
Padding="6,4"
|
||||
Style="{StaticResource FlattenTextBox}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="PART_EditableTextBox" />
|
||||
IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Style="{StaticResource FlattenTextBox}" />
|
||||
</Border>
|
||||
<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>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Opacity" TargetName="border" Value="0.56" />
|
||||
<Setter TargetName="border" Property="Opacity" Value="0.56" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocusWithin" Value="True" />
|
||||
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="True">
|
||||
<Setter Property="Effect" TargetName="dropDownBorder" Value="{DynamicResource PopupShadow}" />
|
||||
<Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="True">
|
||||
<Setter TargetName="dropDownBorder" Property="Effect" Value="{DynamicResource PopupShadow}" />
|
||||
</Trigger>
|
||||
<Trigger Property="HasItems" Value="False">
|
||||
<Setter Property="Height" TargetName="dropDownBorder" Value="95" />
|
||||
<Setter TargetName="dropDownBorder" Property="Height" Value="95" />
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
@@ -201,90 +222,107 @@
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
|
||||
</MultiTrigger>
|
||||
<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="False">
|
||||
<Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}" />
|
||||
<Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}" />
|
||||
<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>
|
||||
|
||||
<!-- 默认控件样式 -->
|
||||
<ControlTemplate TargetType="{x:Type ComboBox}" x:Key="ComboBoxTemplate">
|
||||
<Grid SnapsToDevicePixels="True" x:Name="templateRoot">
|
||||
<!-- 默认控件模板 -->
|
||||
<ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}">
|
||||
<Grid x:Name="templateRoot" SnapsToDevicePixels="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0" />
|
||||
<ColumnDefinition Width="0" MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Popup
|
||||
AllowsTransparency="True"
|
||||
x:Name="PART_Popup"
|
||||
Grid.ColumnSpan="2"
|
||||
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Margin="-8"
|
||||
AllowsTransparency="True"
|
||||
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Placement="Bottom"
|
||||
PopupAnimation="Slide"
|
||||
VerticalOffset="4"
|
||||
x:Name="PART_Popup">
|
||||
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"
|
||||
Margin="8"
|
||||
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
|
||||
x:Name="dropDownBorder">
|
||||
<ScrollViewer Margin="4,3" x:Name="DropDownScrollViewer">
|
||||
<Grid RenderOptions.ClearTypeHint="Enabled" x:Name="grid">
|
||||
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"
|
||||
Width="0"
|
||||
x:Name="canvas">
|
||||
VerticalAlignment="Top">
|
||||
<Rectangle
|
||||
Fill="{Binding Background, ElementName=dropDownBorder}"
|
||||
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
|
||||
x:Name="opaqueRect"
|
||||
Width="{Binding ActualWidth, ElementName=dropDownBorder}"
|
||||
x:Name="opaqueRect" />
|
||||
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
|
||||
Fill="{Binding Background, ElementName=dropDownBorder}" />
|
||||
</Canvas>
|
||||
<ItemsPresenter
|
||||
x:Name="ItemsPresenter"
|
||||
KeyboardNavigation.DirectionalNavigation="Contained"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
x:Name="ItemsPresenter" />
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
|
||||
</Popup>
|
||||
<ToggleButton
|
||||
x:Name="toggleButton"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="-4"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Margin="-4"
|
||||
Style="{StaticResource ComboBoxToggleButton}"
|
||||
x:Name="toggleButton" />
|
||||
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>
|
||||
<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}"
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
IsHitTestVisible="False"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="contentPresenter" />
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="True">
|
||||
<Setter Property="Effect" TargetName="dropDownBorder" Value="{DynamicResource PopupShadow}" />
|
||||
<Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="True">
|
||||
<Setter TargetName="dropDownBorder" Property="Effect" Value="{DynamicResource PopupShadow}" />
|
||||
</Trigger>
|
||||
<Trigger Property="HasItems" Value="False">
|
||||
<Setter Property="Height" TargetName="dropDownBorder" Value="95" />
|
||||
<Setter TargetName="dropDownBorder" Property="Height" Value="95" />
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
@@ -293,22 +331,23 @@
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
|
||||
</MultiTrigger>
|
||||
<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="False">
|
||||
<Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}" />
|
||||
<Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}" />
|
||||
<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 TargetType="{x:Type ComboBox}" x:Key="ComboBoxDefault">
|
||||
<!-- 默认ComboBox样式 -->
|
||||
<Style x:Key="ComboBoxDefault" 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="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="assists:SelectorAssist.Placeholder" Value="请选择..." />
|
||||
<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" />
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="True" />
|
||||
@@ -341,45 +380,45 @@
|
||||
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
|
||||
<Grid Margin="0,1">
|
||||
<Border
|
||||
x:Name="Bd"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="True"
|
||||
x:Name="Bd">
|
||||
SnapsToDevicePixels="True">
|
||||
<ContentPresenter
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</Border>
|
||||
<!-- 选中标记 -->
|
||||
<Border
|
||||
x:Name="box"
|
||||
CornerRadius="4"
|
||||
Visibility="Hidden"
|
||||
x:Name="box">
|
||||
Visibility="Hidden">
|
||||
<Border
|
||||
Background="{DynamicResource PrimaryNormalBrush}"
|
||||
CornerRadius="2"
|
||||
HorizontalAlignment="Left"
|
||||
Width="4"
|
||||
Margin="2,4"
|
||||
Width="4" />
|
||||
HorizontalAlignment="Left"
|
||||
Background="{DynamicResource PrimaryNormalBrush}"
|
||||
CornerRadius="2" />
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Visibility" TargetName="box" Value="Visible" />
|
||||
<Setter TargetName="box" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource BackgroundFloatingBrush}" />
|
||||
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" />
|
||||
</Trigger>
|
||||
<!--<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="Bd"
|
||||
Value="{StaticResource FocusBorderBrush}"/>
|
||||
Value="{StaticResource AdditionalBlueColor}"/>
|
||||
</Trigger>-->
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
@@ -388,7 +427,7 @@
|
||||
</Style>
|
||||
|
||||
<!-- 工具栏下拉Toggle -->
|
||||
<Style TargetType="{x:Type ToggleButton}" x:Key="ToolbarComboBoxToggleButton">
|
||||
<Style x:Key="ToolbarComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
@@ -397,47 +436,47 @@
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<Border
|
||||
x:Name="border"
|
||||
Margin="4"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4"
|
||||
Margin="4"
|
||||
SnapsToDevicePixels="True"
|
||||
x:Name="border">
|
||||
SnapsToDevicePixels="True">
|
||||
<!-- 下拉箭头 -->
|
||||
<Border
|
||||
x:Name="splitBorder"
|
||||
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
|
||||
Margin="0"
|
||||
HorizontalAlignment="Right"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="1"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0"
|
||||
SnapsToDevicePixels="True"
|
||||
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
|
||||
x:Name="splitBorder">
|
||||
SnapsToDevicePixels="True">
|
||||
<Path
|
||||
Data="M 0,0 L 4,3 L 8,0"
|
||||
HorizontalAlignment="Center"
|
||||
x:Name="arrow"
|
||||
Margin="0"
|
||||
Stroke="{DynamicResource TextPrimaryBrush}"
|
||||
StrokeThickness="1"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
x:Name="arrow" />
|
||||
Data="M 0,0 L 4,3 L 8,0"
|
||||
Stroke="{DynamicResource TextPrimaryBrush}"
|
||||
StrokeThickness="1" />
|
||||
</Border>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>
|
||||
<!-- 下压效果 -->
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||||
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||||
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||||
</Trigger>
|
||||
<!-- 按钮禁用效果 -->
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Fill" TargetName="arrow" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter Property="Background" TargetName="border" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter TargetName="arrow" Property="Fill" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter TargetName="border" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
@@ -445,82 +484,82 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
<!-- 工具栏默认样式 -->
|
||||
<ControlTemplate TargetType="{x:Type ComboBox}" x:Key="ToolBarComboBoxTemplate">
|
||||
<Grid SnapsToDevicePixels="True" x:Name="templateRoot">
|
||||
<ControlTemplate x:Key="ToolBarComboBoxTemplate" TargetType="{x:Type ComboBox}">
|
||||
<Grid x:Name="templateRoot" SnapsToDevicePixels="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0" />
|
||||
<ColumnDefinition Width="0" MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Popup
|
||||
AllowsTransparency="True"
|
||||
x:Name="PART_Popup"
|
||||
Grid.ColumnSpan="2"
|
||||
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Margin="-8"
|
||||
AllowsTransparency="True"
|
||||
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Placement="Bottom"
|
||||
PopupAnimation="Slide"
|
||||
VerticalOffset="4"
|
||||
x:Name="PART_Popup">
|
||||
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"
|
||||
Margin="8"
|
||||
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
|
||||
x:Name="dropDownBorder">
|
||||
<ScrollViewer Margin="4,3" x:Name="DropDownScrollViewer">
|
||||
<Grid RenderOptions.ClearTypeHint="Enabled" x:Name="grid">
|
||||
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"
|
||||
Width="0"
|
||||
x:Name="canvas">
|
||||
VerticalAlignment="Top">
|
||||
<Rectangle
|
||||
Fill="{Binding Background, ElementName=dropDownBorder}"
|
||||
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
|
||||
x:Name="opaqueRect"
|
||||
Width="{Binding ActualWidth, ElementName=dropDownBorder}"
|
||||
x:Name="opaqueRect" />
|
||||
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
|
||||
Fill="{Binding Background, ElementName=dropDownBorder}" />
|
||||
</Canvas>
|
||||
<ItemsPresenter
|
||||
x:Name="ItemsPresenter"
|
||||
KeyboardNavigation.DirectionalNavigation="Contained"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
x:Name="ItemsPresenter" />
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
|
||||
</Popup>
|
||||
<ToggleButton
|
||||
x:Name="toggleButton"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="-4"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Margin="-4"
|
||||
Style="{StaticResource ToolbarComboBoxToggleButton}"
|
||||
x:Name="toggleButton" />
|
||||
Style="{StaticResource ToolbarComboBoxToggleButton}" />
|
||||
<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}"
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
IsHitTestVisible="False"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="contentPresenter" />
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="True">
|
||||
<Setter Property="Effect" TargetName="dropDownBorder" Value="{DynamicResource PopupShadow}" />
|
||||
<Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="True">
|
||||
<Setter TargetName="dropDownBorder" Property="Effect" Value="{DynamicResource PopupShadow}" />
|
||||
</Trigger>
|
||||
<Trigger Property="HasItems" Value="False">
|
||||
<Setter Property="Height" TargetName="dropDownBorder" Value="95" />
|
||||
<Setter TargetName="dropDownBorder" Property="Height" Value="95" />
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
@@ -529,18 +568,18 @@
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
|
||||
</MultiTrigger>
|
||||
<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="False">
|
||||
<Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}" />
|
||||
<Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}" />
|
||||
<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="{x:Static ToolBar.ComboBoxStyleKey}"
|
||||
BasedOn="{StaticResource ComboBoxDefault}"
|
||||
TargetType="{x:Type ComboBox}"
|
||||
x:Key="{x:Static ToolBar.ComboBoxStyleKey}">
|
||||
TargetType="{x:Type ComboBox}">
|
||||
<Setter Property="Margin" Value="2" />
|
||||
<Setter Property="Padding" Value="4,2" />
|
||||
<Setter Property="Template" Value="{StaticResource ToolBarComboBoxTemplate}" />
|
||||
|
||||
Reference in New Issue
Block a user