589 lines
31 KiB
XML
589 lines
31 KiB
XML
<ResourceDictionary
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
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
|
|
Storyboard.TargetName="border"
|
|
Storyboard.TargetProperty="Intensity"
|
|
To="0.8"
|
|
Duration="0:0:0.2" />
|
|
<BooleanAnimationUsingKeyFrames
|
|
Storyboard.TargetName="border"
|
|
Storyboard.TargetProperty="ShaderEnabled"
|
|
Duration="0">
|
|
<DiscreteBooleanKeyFrame KeyTime="0" Value="True" />
|
|
</BooleanAnimationUsingKeyFrames>
|
|
</Storyboard>
|
|
<!-- 按钮取消高亮 -->
|
|
<Storyboard x:Key="Button.LeaveEffect">
|
|
<DoubleAnimation
|
|
Storyboard.TargetName="border"
|
|
Storyboard.TargetProperty="Intensity"
|
|
To="0"
|
|
Duration="0:0:0.2" />
|
|
<BooleanAnimationUsingKeyFrames
|
|
Storyboard.TargetName="border"
|
|
Storyboard.TargetProperty="ShaderEnabled"
|
|
Duration="0:0:0.2">
|
|
<DiscreteBooleanKeyFrame KeyTime="0:0:0.2" Value="False" />
|
|
</BooleanAnimationUsingKeyFrames>
|
|
</Storyboard>
|
|
<!-- 按钮按下 -->
|
|
<Storyboard x:Key="Button.PressEffect">
|
|
<DoubleAnimation
|
|
Storyboard.TargetName="border"
|
|
Storyboard.TargetProperty="Intensity"
|
|
To="0.4"
|
|
Duration="0" />
|
|
</Storyboard>
|
|
|
|
<Style x:Key="ComboBoxToggleButton" 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}">
|
|
<svd:EmbossBorder
|
|
x:Name="border"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="4"
|
|
Intensity="0"
|
|
ShaderEnabled="False"
|
|
SnapsToDevicePixels="True">
|
|
<!-- 下拉箭头 -->
|
|
<Border
|
|
x:Name="splitBorder"
|
|
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
|
|
Margin="0"
|
|
HorizontalAlignment="Right"
|
|
BorderBrush="Transparent"
|
|
BorderThickness="1"
|
|
SnapsToDevicePixels="True">
|
|
<Path
|
|
x:Name="arrow"
|
|
Margin="0"
|
|
HorizontalAlignment="Center"
|
|
VerticalAlignment="Center"
|
|
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 TargetName="border" Property="BorderBrush" Value="{DynamicResource BorderGradientBrush}" />
|
|
<Trigger.EnterActions>
|
|
<BeginStoryboard x:Name="showEffectBegin" Storyboard="{StaticResource Button.FocusEffect}" />
|
|
</Trigger.EnterActions>
|
|
<Trigger.ExitActions>
|
|
<BeginStoryboard Storyboard="{StaticResource Button.LeaveEffect}" />
|
|
</Trigger.ExitActions>
|
|
</Trigger>
|
|
<!-- 缩减阴影,下压效果 -->
|
|
<Trigger Property="IsPressed" Value="True">
|
|
<Trigger.EnterActions>
|
|
<BeginStoryboard x:Name="pressBegin" Storyboard="{StaticResource Button.PressEffect}" />
|
|
</Trigger.EnterActions>
|
|
<Trigger.ExitActions>
|
|
<RemoveStoryboard BeginStoryboardName="pressBegin" />
|
|
</Trigger.ExitActions>
|
|
</Trigger>
|
|
<Trigger Property="IsChecked" Value="True">
|
|
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource BorderGradientBrush}" />
|
|
</Trigger>
|
|
<!-- 按钮禁用效果 -->
|
|
<Trigger Property="IsEnabled" Value="False">
|
|
<Setter TargetName="arrow" Property="Fill" Value="{DynamicResource TextDisabledBrush}" />
|
|
<Setter TargetName="border" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
|
</Trigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
|
|
<!-- 可编辑模板 -->
|
|
<ControlTemplate x:Key="ComboBoxEditableTemplate" 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"
|
|
Margin="-4"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
|
Style="{StaticResource ComboBoxToggleButton}" />
|
|
|
|
<Border
|
|
x:Name="border"
|
|
Grid.Column="0"
|
|
Margin="{TemplateBinding BorderThickness}">
|
|
<TextBox
|
|
x:Name="PART_EditableTextBox"
|
|
Margin="{TemplateBinding Padding}"
|
|
Padding="6,4"
|
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
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 TargetName="border" Property="Opacity" Value="0.56" />
|
|
</Trigger>
|
|
<Trigger Property="IsKeyboardFocusWithin" Value="True" />
|
|
<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>
|
|
|
|
<!-- 默认控件模板 -->
|
|
<ControlTemplate x:Key="ComboBoxTemplate" 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"
|
|
Margin="-4"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
|
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}"
|
|
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>
|
|
<!-- 默认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" />
|
|
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
|
|
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
|
<Setter Property="Template" Value="{StaticResource ComboBoxTemplate}" />
|
|
<Style.Triggers>
|
|
<Trigger Property="IsEditable" Value="True">
|
|
<Setter Property="IsTabStop" Value="False" />
|
|
<Setter Property="Padding" Value="3" />
|
|
<Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}" />
|
|
</Trigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
<!-- 默认下拉样式 -->
|
|
<Style BasedOn="{StaticResource ComboBoxDefault}" TargetType="{x:Type ComboBox}" />
|
|
|
|
<!-- 内容样式 -->
|
|
<Style TargetType="{x:Type ComboBoxItem}">
|
|
<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" />
|
|
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<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"
|
|
SnapsToDevicePixels="True">
|
|
<ContentPresenter
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
|
</Border>
|
|
<!-- 选中标记 -->
|
|
<Border
|
|
x:Name="box"
|
|
CornerRadius="4"
|
|
Visibility="Hidden">
|
|
<Border
|
|
Width="4"
|
|
Margin="2,4"
|
|
HorizontalAlignment="Left"
|
|
Background="{DynamicResource PrimaryNormalBrush}"
|
|
CornerRadius="2" />
|
|
</Border>
|
|
</Grid>
|
|
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="IsEnabled" Value="False">
|
|
<Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
|
</Trigger>
|
|
<Trigger Property="IsSelected" Value="True">
|
|
<Setter TargetName="box" Property="Visibility" Value="Visible" />
|
|
</Trigger>
|
|
<Trigger Property="IsMouseOver" Value="True">
|
|
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" />
|
|
</Trigger>
|
|
<!--<Trigger Property="IsKeyboardFocused" Value="True">
|
|
<Setter Property="BorderBrush" TargetName="Bd"
|
|
Value="{StaticResource AdditionalBlueColor}"/>
|
|
</Trigger>-->
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
|
|
<!-- 工具栏下拉Toggle -->
|
|
<Style x:Key="ToolbarComboBoxToggleButton" 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"
|
|
Margin="4"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="4"
|
|
SnapsToDevicePixels="True">
|
|
<!-- 下拉箭头 -->
|
|
<Border
|
|
x:Name="splitBorder"
|
|
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
|
|
Margin="0"
|
|
HorizontalAlignment="Right"
|
|
BorderBrush="Transparent"
|
|
BorderThickness="1"
|
|
SnapsToDevicePixels="True">
|
|
<Path
|
|
x:Name="arrow"
|
|
Margin="0"
|
|
HorizontalAlignment="Center"
|
|
VerticalAlignment="Center"
|
|
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 TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
|
|
</Trigger>
|
|
<!-- 下压效果 -->
|
|
<Trigger Property="IsPressed" Value="True">
|
|
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
|
|
</Trigger>
|
|
<Trigger Property="IsChecked" Value="True">
|
|
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
|
|
</Trigger>
|
|
<!-- 按钮禁用效果 -->
|
|
<Trigger Property="IsEnabled" Value="False">
|
|
<Setter TargetName="arrow" Property="Fill" Value="{DynamicResource TextDisabledBrush}" />
|
|
<Setter TargetName="border" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
|
</Trigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
<!-- 工具栏默认样式 -->
|
|
<ControlTemplate x:Key="ToolBarComboBoxTemplate" 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"
|
|
Margin="-4"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
|
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}"
|
|
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="{x:Static ToolBar.ComboBoxStyleKey}"
|
|
BasedOn="{StaticResource ComboBoxDefault}"
|
|
TargetType="{x:Type ComboBox}">
|
|
<Setter Property="Margin" Value="2" />
|
|
<Setter Property="Padding" Value="4,2" />
|
|
<Setter Property="Template" Value="{StaticResource ToolBarComboBoxTemplate}" />
|
|
</Style>
|
|
|
|
|
|
</ResourceDictionary> |