功能完善
This commit is contained in:
551
NeuWPF/NeoUI/Controls/TextBoxStyle.xaml
Normal file
551
NeuWPF/NeoUI/Controls/TextBoxStyle.xaml
Normal file
@@ -0,0 +1,551 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:assists="clr-namespace:NeumUI.Assists"
|
||||
xmlns:controls="clr-namespace:NeumUI.Controls"
|
||||
xmlns:conv="clr-namespace:NeumUI.Converters"
|
||||
xmlns:svd="clr-namespace:NeumUI.Controls.Decorations"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/NeumUI;component/Controls/SymbolIcon.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style
|
||||
BasedOn="{StaticResource SymbolIconStyle}"
|
||||
TargetType="controls:SymbolIcon"
|
||||
x:Key="ToolIcon">
|
||||
<!-- <Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" /> -->
|
||||
<!-- <Setter Property="FontSize" Value="16" /> -->
|
||||
<Setter Property="Opacity" Value="0.65" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Opacity" Value="1" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type TextBox}" x:Key="NeuTextBox">
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundContainerBrush}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="assists:InputAssist.PlaceholderBrush" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Padding" Value="10,4" />
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="AllowDrop" Value="True" />
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
||||
<Setter Property="ContextMenu" Value="{DynamicResource TextBoxContextMenu}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<ControlTemplate.Resources>
|
||||
<!-- 聚焦对象 -->
|
||||
<Storyboard x:Key="TextBox.FocusEffect">
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.2"
|
||||
Storyboard.TargetName="slot"
|
||||
Storyboard.TargetProperty="Intensity"
|
||||
To="0.5" />
|
||||
</Storyboard>
|
||||
<!-- 取消聚焦对象 -->
|
||||
<Storyboard x:Key="TextBox.LeaveEffect">
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.2"
|
||||
Storyboard.TargetName="slot"
|
||||
Storyboard.TargetProperty="Intensity"
|
||||
To="0.2" />
|
||||
</Storyboard>
|
||||
</ControlTemplate.Resources>
|
||||
|
||||
<Grid>
|
||||
<svd:SlotBorder
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Intensity="0.2"
|
||||
Margin="-4"
|
||||
SnapsToDevicePixels="True"
|
||||
x:Name="slot" />
|
||||
<svd:EmbossBorder
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Intensity="0.4"
|
||||
Margin="-4"
|
||||
SnapsToDevicePixels="True"
|
||||
Visibility="Collapsed"
|
||||
x:Name="emboss" />
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<!-- 前缀 -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<!-- 输入框 -->
|
||||
<ColumnDefinition Width="*" />
|
||||
<!-- 清空按钮 -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<!-- 后缀 -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding assists:InputAssist.Prefix}"
|
||||
Focusable="False"
|
||||
Grid.Column="0"
|
||||
Margin="1,0,5,0"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="Prefix" />
|
||||
<!-- 水印 -->
|
||||
<TextBlock
|
||||
Focusable="False"
|
||||
Foreground="{TemplateBinding assists:InputAssist.PlaceholderBrush}"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Margin="5,0,0,0"
|
||||
Text="{TemplateBinding assists:InputAssist.Placeholder}"
|
||||
TextAlignment="{TemplateBinding TextAlignment}"
|
||||
TextWrapping="{TemplateBinding TextWrapping}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Visibility="Collapsed"
|
||||
x:Name="Placeholder" />
|
||||
<!-- Margin="{Binding Padding, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static conv:ThicknessReverseConverter.Instance}}" -->
|
||||
<ScrollViewer
|
||||
Background="{x:Null}"
|
||||
BorderThickness="0"
|
||||
Focusable="False"
|
||||
Grid.Column="1"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
IsTabStop="False"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
VerticalScrollBarVisibility="Hidden"
|
||||
x:Name="PART_ContentHost" />
|
||||
<!-- 清空按钮 -->
|
||||
<controls:SymbolIcon
|
||||
Grid.Column="2"
|
||||
Style="{StaticResource ToolIcon}"
|
||||
Symbol="Close"
|
||||
Visibility="Collapsed"
|
||||
x:Name="CloseIcon" />
|
||||
|
||||
<!-- Suffix -->
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding assists:InputAssist.Suffix}"
|
||||
Focusable="False"
|
||||
Grid.Column="3"
|
||||
Margin="5,0,1,0"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="Suffix" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding Text, Mode=OneWay, RelativeSource={RelativeSource Self}}" Value="">
|
||||
<Setter Property="Visibility" TargetName="Placeholder" Value="Visible" />
|
||||
</DataTrigger>
|
||||
<!-- Prefix & Suffix -->
|
||||
<Trigger Property="Content" SourceName="Prefix" Value="{x:Null}">
|
||||
<Setter Property="Visibility" TargetName="Prefix" Value="Collapsed" />
|
||||
</Trigger>
|
||||
<Trigger Property="Content" SourceName="Suffix" Value="{x:Null}">
|
||||
<Setter Property="Visibility" TargetName="Suffix" Value="Collapsed" />
|
||||
</Trigger>
|
||||
|
||||
<MultiTrigger>
|
||||
<!-- 可清空 -->
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="assists:InputAssist.Clearable" Value="True" />
|
||||
<Condition Property="Visibility" SourceName="Placeholder" Value="Collapsed" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Visibility" TargetName="CloseIcon" Value="Visible" />
|
||||
<Setter Property="assists:InputAssist.ClearEnabled" TargetName="CloseIcon" Value="True" />
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter Property="ShaderEnabled" TargetName="slot" Value="False" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsReadOnly" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}" />
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsFocused" Value="True">
|
||||
<Setter Property="TextElement.Foreground" TargetName="Prefix" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
<Setter Property="TextElement.Foreground" TargetName="Suffix" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
<Setter Property="Visibility" TargetName="slot" Value="Collapsed" />
|
||||
<Setter Property="Visibility" TargetName="emboss" Value="Visible" />
|
||||
</Trigger>
|
||||
|
||||
<!--<Trigger Property="IsKeyboardFocused" Value="True" />-->
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="False" />
|
||||
<Condition Property="IsKeyboardFocused" Value="False" />
|
||||
</MultiTrigger.Conditions>
|
||||
<MultiTrigger.EnterActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource TextBox.LeaveEffect}" />
|
||||
</MultiTrigger.EnterActions>
|
||||
<MultiTrigger.ExitActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource TextBox.FocusEffect}" />
|
||||
</MultiTrigger.ExitActions>
|
||||
</MultiTrigger>
|
||||
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="True" />
|
||||
<Condition Property="IsSelectionActive" Value="False" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}" />
|
||||
</MultiTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type TextBox}" x:Key="DefaultTextBox">
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundContainerBrush}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="assists:InputAssist.PlaceholderBrush" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Padding" Value="3" />
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="AllowDrop" Value="True" />
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
||||
<Setter Property="ContextMenu" Value="{DynamicResource TextBoxContextMenu}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<ControlTemplate.Resources>
|
||||
<!-- 聚焦对象 -->
|
||||
<Storyboard x:Key="TextBox.FocusEffect">
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.2"
|
||||
Storyboard.TargetName="slot"
|
||||
Storyboard.TargetProperty="Intensity"
|
||||
To="0.5" />
|
||||
</Storyboard>
|
||||
<!-- 取消聚焦对象 -->
|
||||
<Storyboard x:Key="TextBox.LeaveEffect">
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.2"
|
||||
Storyboard.TargetName="slot"
|
||||
Storyboard.TargetProperty="Intensity"
|
||||
To="0.2" />
|
||||
</Storyboard>
|
||||
</ControlTemplate.Resources>
|
||||
|
||||
<svd:SlotBorder
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Intensity="0.2"
|
||||
SnapsToDevicePixels="True"
|
||||
x:Name="slot">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<!-- 前缀 -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<!-- 输入框 -->
|
||||
<ColumnDefinition Width="*" />
|
||||
<!-- 清空按钮 -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<!-- 后缀 -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding assists:InputAssist.Prefix}"
|
||||
Focusable="False"
|
||||
Grid.Column="0"
|
||||
Margin="1,0,5,0"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="Prefix" />
|
||||
<!-- 水印 -->
|
||||
<TextBlock
|
||||
Focusable="False"
|
||||
Foreground="{TemplateBinding assists:InputAssist.PlaceholderBrush}"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Margin="5,0,0,0"
|
||||
Text="{TemplateBinding assists:InputAssist.Placeholder}"
|
||||
TextAlignment="{TemplateBinding TextAlignment}"
|
||||
TextWrapping="{TemplateBinding TextWrapping}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Visibility="Collapsed"
|
||||
x:Name="Placeholder" />
|
||||
<!-- Margin="{Binding Padding, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static conv:ThicknessReverseConverter.Instance}}" -->
|
||||
<ScrollViewer
|
||||
Background="{x:Null}"
|
||||
BorderThickness="0"
|
||||
Focusable="False"
|
||||
Grid.Column="1"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
IsTabStop="False"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
VerticalScrollBarVisibility="Hidden"
|
||||
x:Name="PART_ContentHost" />
|
||||
<!-- 清空按钮 -->
|
||||
<controls:SymbolIcon
|
||||
Grid.Column="2"
|
||||
Style="{StaticResource ToolIcon}"
|
||||
Symbol="Close"
|
||||
Visibility="Collapsed"
|
||||
x:Name="CloseIcon" />
|
||||
|
||||
<!-- Suffix -->
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding assists:InputAssist.Suffix}"
|
||||
Focusable="False"
|
||||
Grid.Column="3"
|
||||
Margin="5,0,1,0"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="Suffix" />
|
||||
</Grid>
|
||||
</svd:SlotBorder>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding Text, Mode=OneWay, RelativeSource={RelativeSource Self}}" Value="">
|
||||
<Setter Property="Visibility" TargetName="Placeholder" Value="Visible" />
|
||||
</DataTrigger>
|
||||
<!-- Prefix & Suffix -->
|
||||
<Trigger Property="Content" SourceName="Prefix" Value="{x:Null}">
|
||||
<Setter Property="Visibility" TargetName="Prefix" Value="Collapsed" />
|
||||
</Trigger>
|
||||
<Trigger Property="Content" SourceName="Suffix" Value="{x:Null}">
|
||||
<Setter Property="Visibility" TargetName="Suffix" Value="Collapsed" />
|
||||
</Trigger>
|
||||
|
||||
<MultiTrigger>
|
||||
<!-- 可清空 -->
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="assists:InputAssist.Clearable" Value="True" />
|
||||
<Condition Property="Visibility" SourceName="Placeholder" Value="Collapsed" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Visibility" TargetName="CloseIcon" Value="Visible" />
|
||||
<Setter Property="assists:InputAssist.ClearEnabled" TargetName="CloseIcon" Value="True" />
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter Property="ShaderEnabled" TargetName="slot" Value="False" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsReadOnly" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}" />
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsFocused" Value="True">
|
||||
<Setter Property="TextElement.Foreground" TargetName="Prefix" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
<Setter Property="TextElement.Foreground" TargetName="Suffix" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>
|
||||
|
||||
<!--<Trigger Property="IsKeyboardFocused" Value="True" />-->
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="False" />
|
||||
<Condition Property="IsKeyboardFocused" Value="False" />
|
||||
</MultiTrigger.Conditions>
|
||||
<MultiTrigger.EnterActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource TextBox.LeaveEffect}" />
|
||||
</MultiTrigger.EnterActions>
|
||||
<MultiTrigger.ExitActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource TextBox.FocusEffect}" />
|
||||
</MultiTrigger.ExitActions>
|
||||
</MultiTrigger>
|
||||
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="True" />
|
||||
<Condition Property="IsSelectionActive" Value="False" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}" />
|
||||
</MultiTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!-- 默认文本框样式 -->
|
||||
<Style BasedOn="{StaticResource DefaultTextBox}" TargetType="{x:Type TextBox}" />
|
||||
<!-- 富文本样式 -->
|
||||
<Style TargetType="{x:Type RichTextBox}">
|
||||
<Style.Resources>
|
||||
<Style TargetType="{x:Type FlowDocument}" x:Key="{x:Type FlowDocument}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
</Style>
|
||||
<Style
|
||||
BasedOn="{StaticResource {x:Type Hyperlink}}"
|
||||
TargetType="{x:Type Hyperlink}"
|
||||
x:Key="{x:Type Hyperlink}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Style.Resources>
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundContainerBrush}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<!--<Setter Property="Padding" Value="3,3,3,2" />-->
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="AllowDrop" Value="True" />
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
||||
<Setter Property="ContextMenu" Value="{DynamicResource TextBoxContextMenu}" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="MinWidth" Value="10" />
|
||||
<Setter Property="Padding" Value="2,4" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type RichTextBox}">
|
||||
<ControlTemplate.Resources>
|
||||
<!-- 聚焦对象 -->
|
||||
<Storyboard x:Key="TextBox.FocusEffect">
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.2"
|
||||
Storyboard.TargetName="slot"
|
||||
Storyboard.TargetProperty="Intensity"
|
||||
To="0.5" />
|
||||
</Storyboard>
|
||||
<!-- 取消聚焦对象 -->
|
||||
<Storyboard x:Key="TextBox.LeaveEffect">
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.2"
|
||||
Storyboard.TargetName="slot"
|
||||
Storyboard.TargetProperty="Intensity"
|
||||
To="0.2" />
|
||||
</Storyboard>
|
||||
</ControlTemplate.Resources>
|
||||
<svd:SlotBorder
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Intensity="0.2"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="True"
|
||||
x:Name="slot">
|
||||
<!-- Margin="{Binding Padding, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static conv:ThicknessReverseConverter.Instance}}" -->
|
||||
<ScrollViewer
|
||||
Background="{x:Null}"
|
||||
BorderThickness="0"
|
||||
Focusable="False"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
IsTabStop="False"
|
||||
VerticalScrollBarVisibility="Hidden"
|
||||
x:Name="PART_ContentHost" />
|
||||
</svd:SlotBorder>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter Property="ShaderEnabled" TargetName="slot" Value="False" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsReadOnly" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}" />
|
||||
</Trigger>
|
||||
|
||||
<!--<Trigger Property="IsMouseOver" Value="True" />-->
|
||||
|
||||
<!--<Trigger Property="IsKeyboardFocused" Value="True" />-->
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="False" />
|
||||
<Condition Property="IsKeyboardFocused" Value="False" />
|
||||
</MultiTrigger.Conditions>
|
||||
<MultiTrigger.EnterActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource TextBox.LeaveEffect}" />
|
||||
</MultiTrigger.EnterActions>
|
||||
<MultiTrigger.ExitActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource TextBox.FocusEffect}" />
|
||||
</MultiTrigger.ExitActions>
|
||||
</MultiTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="True" />
|
||||
<Condition Property="IsSelectionActive" Value="False" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}" />
|
||||
</MultiTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!-- 工具栏文本框样式 -->
|
||||
<Style TargetType="{x:Type TextBox}" x:Key="{x:Static ToolBar.TextBoxStyleKey}">
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Padding" Value="4,2" />
|
||||
<Setter Property="Margin" Value="2" />
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="AllowDrop" Value="True" />
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4"
|
||||
SnapsToDevicePixels="True"
|
||||
x:Name="border">
|
||||
<ScrollViewer
|
||||
Focusable="False"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Hidden"
|
||||
x:Name="PART_ContentHost" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="TextElement.Foreground" TargetName="PART_ContentHost" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource PrimaryFocusedBrush}" />
|
||||
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user