Files
ShrlAlgoToolkit/Melskin/Controls/TextBox.xaml

786 lines
45 KiB
Plaintext
Raw Normal View History

2025-08-20 12:10:13 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2026-02-20 15:31:44 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
2026-01-02 17:30:41 +08:00
xmlns:assists="clr-namespace:Melskin.Assists"
xmlns:controls="clr-namespace:Melskin.Controls"
2026-02-20 15:31:44 +08:00
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations">
2025-08-20 12:10:13 +08:00
<ResourceDictionary.MergedDictionaries>
2026-01-02 17:30:41 +08:00
<ResourceDictionary Source="/Melskin;component/Controls/IconElement.xaml" />
<ResourceDictionary Source="/Melskin;component/Themes/Animations.xaml" />
2025-08-20 12:10:13 +08:00
</ResourceDictionary.MergedDictionaries>
2025-12-23 21:35:54 +08:00
<!-- Float为凹陷和凸起切换的交互 -->
2026-02-20 15:31:44 +08:00
<Style x:Key="FloatTextBoxStyle" TargetType="{x:Type TextBox}">
2025-08-26 21:33:20 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-20 12:10:13 +08:00
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<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}" />
2025-08-20 12:10:35 +08:00
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<StackPanel>
<AdornedElementPlaceholder Name="Adorner" />
2025-09-04 22:39:00 +08:00
<TextBlock
2026-01-02 17:30:30 +08:00
HorizontalAlignment="Right"
2026-02-20 15:31:44 +08:00
Foreground="{DynamicResource ErrorBrush}"
2025-09-04 22:39:00 +08:00
Text="{Binding ElementName=Adorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}" />
2025-08-20 12:10:35 +08:00
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
2025-08-20 12:10:13 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<decorations:SlotBorder
2026-02-20 15:31:44 +08:00
x:Name="slot"
Margin="-4"
2025-08-20 12:10:13 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Intensity="0.2"
2026-02-20 15:31:44 +08:00
SnapsToDevicePixels="True" />
2026-01-02 17:30:30 +08:00
<decorations:EmbossBorder
2026-02-20 15:31:44 +08:00
x:Name="emboss"
Margin="-4"
2025-08-20 12:10:13 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Intensity="0.4"
SnapsToDevicePixels="True"
2026-02-20 15:31:44 +08:00
Visibility="Collapsed" />
2025-08-20 12:10:13 +08:00
<Grid>
<Grid.ColumnDefinitions>
<!-- 前缀 -->
<ColumnDefinition Width="Auto" />
<!-- 输入框 -->
<ColumnDefinition Width="*" />
<!-- 清空按钮 -->
<ColumnDefinition Width="Auto" />
<!-- 后缀 -->
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="Prefix"
2025-08-20 12:10:13 +08:00
Grid.Column="0"
Margin="1,0,5,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Content="{TemplateBinding assists:InputAssist.Prefix}"
Focusable="False" />
2025-08-20 12:10:13 +08:00
<!-- 水印 -->
<TextBlock
2026-02-20 15:31:44 +08:00
x:Name="Placeholder"
2026-01-02 17:30:30 +08:00
Grid.Column="1"
Margin="5,0,0,0"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
Foreground="{DynamicResource TextPlaceholderBrush}"
2025-12-23 21:35:54 +08:00
Text="{TemplateBinding assists:InputAssist.PlaceholderText}"
2025-08-20 12:10:13 +08:00
TextAlignment="{TemplateBinding TextAlignment}"
TextWrapping="{TemplateBinding TextWrapping}"
2026-02-20 15:31:44 +08:00
Visibility="Collapsed" />
2025-09-04 22:39:00 +08:00
<!-- Margin="{Binding Padding, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:ThicknessReverseConverter.Instance}}" -->
2025-08-20 12:10:13 +08:00
<ScrollViewer
2026-02-20 15:31:44 +08:00
x:Name="PART_ContentHost"
Grid.Column="1"
Padding="{TemplateBinding Padding}"
2025-08-20 12:10:13 +08:00
Background="{x:Null}"
BorderThickness="0"
Focusable="False"
HorizontalScrollBarVisibility="Hidden"
IsTabStop="False"
2026-02-20 15:31:44 +08:00
VerticalScrollBarVisibility="Hidden" />
2025-08-20 12:10:13 +08:00
<!-- 清空按钮 -->
2025-08-20 12:10:35 +08:00
<controls:IconElement
2026-02-20 15:31:44 +08:00
x:Name="CloseIcon"
2025-08-20 12:10:13 +08:00
Grid.Column="2"
Style="{StaticResource ToolIcon}"
Symbol="Close"
2026-02-20 15:31:44 +08:00
Visibility="Collapsed" />
2025-08-20 12:10:13 +08:00
<!-- Suffix -->
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="Suffix"
2025-08-20 12:10:13 +08:00
Grid.Column="3"
Margin="5,0,1,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Content="{TemplateBinding assists:InputAssist.Suffix}"
Focusable="False" />
2025-08-20 12:10:13 +08:00
</Grid>
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Text, Mode=OneWay, RelativeSource={RelativeSource Self}}" Value="">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Placeholder" Property="Visibility" Value="Visible" />
2025-08-20 12:10:13 +08:00
</DataTrigger>
<!-- Prefix & Suffix -->
2026-02-20 15:31:44 +08:00
<Trigger SourceName="Prefix" Property="Content" Value="{x:Null}">
<Setter TargetName="Prefix" Property="Visibility" Value="Collapsed" />
2025-08-20 12:10:13 +08:00
</Trigger>
2026-02-20 15:31:44 +08:00
<Trigger SourceName="Suffix" Property="Content" Value="{x:Null}">
<Setter TargetName="Suffix" Property="Visibility" Value="Collapsed" />
2025-08-20 12:10:13 +08:00
</Trigger>
<MultiTrigger>
<!-- 可清空 -->
<MultiTrigger.Conditions>
<Condition Property="assists:InputAssist.Clearable" Value="True" />
2026-02-20 15:31:44 +08:00
<Condition SourceName="Placeholder" Property="Visibility" Value="Collapsed" />
2025-08-20 12:10:13 +08:00
</MultiTrigger.Conditions>
2026-02-20 15:31:44 +08:00
<Setter TargetName="CloseIcon" Property="Visibility" Value="Visible" />
<Setter TargetName="CloseIcon" Property="assists:InputAssist.ClearEnabled" Value="True" />
2025-08-20 12:10:13 +08:00
</MultiTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
2026-02-20 15:31:44 +08:00
<Setter TargetName="slot" Property="ShaderEnabled" Value="False" />
2025-08-20 12:10:13 +08:00
</Trigger>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}" />
</Trigger>
<Trigger Property="IsFocused" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Prefix" Property="TextElement.Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter TargetName="Suffix" Property="TextElement.Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter TargetName="slot" Property="Visibility" Value="Collapsed" />
<Setter TargetName="emboss" Property="Visibility" Value="Visible" />
2025-08-20 12:10:13 +08:00
</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>
2026-02-20 15:31:44 +08:00
<Style x:Key="SlotTextBoxStyle" TargetType="{x:Type TextBox}">
2025-08-26 21:33:20 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-20 12:10:13 +08:00
<Setter Property="BorderBrush" Value="Transparent" />
2025-12-28 11:47:54 +08:00
<Setter Property="assists:InputAssist.PlaceholderText" Value="请输入..." />
2025-08-20 12:10:13 +08:00
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<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" />
2025-12-28 11:47:54 +08:00
<Setter Property="VerticalAlignment" Value="Center" />
2025-08-20 12:10:13 +08:00
<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}" />
2025-09-04 22:39:00 +08:00
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<StackPanel>
<AdornedElementPlaceholder Name="Adorner" />
<TextBlock
2026-01-02 17:30:30 +08:00
HorizontalAlignment="Right"
2026-02-20 15:31:44 +08:00
Foreground="{DynamicResource ErrorBrush}"
2025-09-04 22:39:00 +08:00
Text="{Binding ElementName=Adorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
2025-08-20 12:10:13 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<ControlTemplate.Resources>
<!-- 聚焦对象 -->
<Storyboard x:Key="TextBox.FocusEffect">
<DoubleAnimation
Storyboard.TargetName="slot"
Storyboard.TargetProperty="Intensity"
2026-02-20 15:31:44 +08:00
To="0.5"
Duration="0:0:0.2" />
2025-08-20 12:10:13 +08:00
</Storyboard>
<!-- 取消聚焦对象 -->
<Storyboard x:Key="TextBox.LeaveEffect">
<DoubleAnimation
Storyboard.TargetName="slot"
Storyboard.TargetProperty="Intensity"
2026-02-20 15:31:44 +08:00
To="0.2"
Duration="0:0:0.2" />
2025-08-20 12:10:13 +08:00
</Storyboard>
</ControlTemplate.Resources>
<decorations:SlotBorder
2026-02-20 15:31:44 +08:00
x:Name="slot"
2025-08-20 12:10:13 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Intensity="0.2"
2026-02-20 15:31:44 +08:00
SnapsToDevicePixels="True">
2025-08-20 12:10:13 +08:00
<Grid>
<Grid.ColumnDefinitions>
<!-- 前缀 -->
<ColumnDefinition Width="Auto" />
<!-- 输入框 -->
<ColumnDefinition Width="*" />
<!-- 清空按钮 -->
<ColumnDefinition Width="Auto" />
<!-- 后缀 -->
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="Prefix"
2025-08-20 12:10:13 +08:00
Grid.Column="0"
Margin="1,0,5,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Content="{TemplateBinding assists:InputAssist.Prefix}"
Focusable="False" />
2025-08-20 12:10:13 +08:00
<!-- 水印 -->
<TextBlock
2026-02-20 15:31:44 +08:00
x:Name="Placeholder"
2026-01-02 17:30:30 +08:00
Grid.Column="1"
Margin="5,0,0,0"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
Foreground="{DynamicResource TextPlaceholderBrush}"
2025-12-23 21:35:54 +08:00
Text="{TemplateBinding assists:InputAssist.PlaceholderText}"
2025-08-20 12:10:13 +08:00
TextAlignment="{TemplateBinding TextAlignment}"
TextWrapping="{TemplateBinding TextWrapping}"
2026-02-20 15:31:44 +08:00
Visibility="Collapsed" />
2025-09-04 22:39:00 +08:00
<!-- Margin="{Binding Padding, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:ThicknessReverseConverter.Instance}}" -->
2025-08-20 12:10:13 +08:00
<ScrollViewer
2026-02-20 15:31:44 +08:00
x:Name="PART_ContentHost"
Grid.Column="1"
Padding="{TemplateBinding Padding}"
2025-08-20 12:10:13 +08:00
Background="{x:Null}"
BorderThickness="0"
Focusable="False"
HorizontalScrollBarVisibility="Hidden"
IsTabStop="False"
2026-02-20 15:31:44 +08:00
VerticalScrollBarVisibility="Hidden" />
2025-08-20 12:10:13 +08:00
<!-- 清空按钮 -->
2025-08-20 12:10:35 +08:00
<controls:IconElement
2026-02-20 15:31:44 +08:00
x:Name="CloseIcon"
2025-08-20 12:10:13 +08:00
Grid.Column="2"
Style="{StaticResource ToolIcon}"
Symbol="Close"
2026-02-20 15:31:44 +08:00
Visibility="Collapsed" />
2025-08-20 12:10:13 +08:00
<!-- Suffix -->
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="Suffix"
2025-08-20 12:10:13 +08:00
Grid.Column="3"
Margin="5,0,1,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Content="{TemplateBinding assists:InputAssist.Suffix}"
Focusable="False" />
2025-08-20 12:10:13 +08:00
</Grid>
</decorations:SlotBorder>
2025-08-20 12:10:13 +08:00
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Text, Mode=OneWay, RelativeSource={RelativeSource Self}}" Value="">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Placeholder" Property="Visibility" Value="Visible" />
2025-08-20 12:10:13 +08:00
</DataTrigger>
<!-- Prefix & Suffix -->
2026-02-20 15:31:44 +08:00
<Trigger SourceName="Prefix" Property="Content" Value="{x:Null}">
<Setter TargetName="Prefix" Property="Visibility" Value="Collapsed" />
2025-08-20 12:10:13 +08:00
</Trigger>
2026-02-20 15:31:44 +08:00
<Trigger SourceName="Suffix" Property="Content" Value="{x:Null}">
<Setter TargetName="Suffix" Property="Visibility" Value="Collapsed" />
2025-08-20 12:10:13 +08:00
</Trigger>
<MultiTrigger>
<!-- 可清空 -->
<MultiTrigger.Conditions>
<Condition Property="assists:InputAssist.Clearable" Value="True" />
2026-02-20 15:31:44 +08:00
<Condition SourceName="Placeholder" Property="Visibility" Value="Collapsed" />
2025-08-20 12:10:13 +08:00
</MultiTrigger.Conditions>
2026-02-20 15:31:44 +08:00
<Setter TargetName="CloseIcon" Property="Visibility" Value="Visible" />
<Setter TargetName="CloseIcon" Property="assists:InputAssist.ClearEnabled" Value="True" />
2025-08-20 12:10:13 +08:00
</MultiTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
2026-02-20 15:31:44 +08:00
<Setter TargetName="slot" Property="ShaderEnabled" Value="False" />
2025-08-20 12:10:13 +08:00
</Trigger>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}" />
</Trigger>
<Trigger Property="IsFocused" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Prefix" Property="TextElement.Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter TargetName="Suffix" Property="TextElement.Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
2025-08-20 12:10:13 +08:00
</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>
2026-02-20 15:31:44 +08:00
<Style x:Key="DefaultTextBoxStyle" TargetType="{x:Type TextBox}">
2025-12-23 21:35:54 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Padding" Value="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="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<StackPanel>
<AdornedElementPlaceholder Name="Adorner" />
<TextBlock
2026-01-02 17:30:30 +08:00
HorizontalAlignment="Right"
2026-02-20 15:31:44 +08:00
Foreground="{DynamicResource ErrorBrush}"
2025-12-23 21:35:54 +08:00
Text="{Binding ElementName=Adorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border
2026-02-20 15:31:44 +08:00
x:Name="ContentBorder"
Padding="{TemplateBinding Padding}"
2025-12-23 21:35:54 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
2026-02-20 15:31:44 +08:00
SnapsToDevicePixels="True">
2025-12-23 21:35:54 +08:00
<Grid>
<Grid.ColumnDefinitions>
<!-- 前缀 -->
<ColumnDefinition Width="Auto" />
<!-- 输入框 -->
<ColumnDefinition Width="*" />
<!-- 清空按钮 -->
<ColumnDefinition Width="Auto" />
<!-- 后缀 -->
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="Prefix"
2025-12-23 21:35:54 +08:00
Grid.Column="0"
Margin="1,0,5,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Content="{TemplateBinding assists:InputAssist.Prefix}"
Focusable="False" />
2025-12-23 21:35:54 +08:00
<!-- 水印 -->
<TextBlock
2026-02-20 15:31:44 +08:00
x:Name="Placeholder"
2026-01-02 17:30:30 +08:00
Grid.Column="1"
Margin="5,0,0,0"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
Foreground="{DynamicResource TextPlaceholderBrush}"
2025-12-23 21:35:54 +08:00
Text="{TemplateBinding assists:InputAssist.PlaceholderText}"
TextAlignment="{TemplateBinding TextAlignment}"
TextWrapping="{TemplateBinding TextWrapping}"
2026-02-20 15:31:44 +08:00
Visibility="Collapsed" />
2025-12-23 21:35:54 +08:00
<!-- Margin="{Binding Padding, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:ThicknessReverseConverter.Instance}}" -->
<ScrollViewer
2026-02-20 15:31:44 +08:00
x:Name="PART_ContentHost"
Grid.Column="1"
2025-12-23 21:35:54 +08:00
Background="{x:Null}"
BorderThickness="0"
Focusable="False"
HorizontalScrollBarVisibility="Hidden"
IsTabStop="False"
2026-02-20 15:31:44 +08:00
VerticalScrollBarVisibility="Hidden" />
2025-12-23 21:35:54 +08:00
<!-- 清空按钮 -->
<controls:IconElement
2026-02-20 15:31:44 +08:00
x:Name="CloseIcon"
2025-12-23 21:35:54 +08:00
Grid.Column="2"
Style="{StaticResource ToolIcon}"
Symbol="Close"
2026-02-20 15:31:44 +08:00
Visibility="Collapsed" />
2025-12-23 21:35:54 +08:00
<!-- Suffix -->
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="Suffix"
2025-12-23 21:35:54 +08:00
Grid.Column="3"
Margin="5,0,1,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
Content="{TemplateBinding assists:InputAssist.Suffix}"
Focusable="False" />
2025-12-23 21:35:54 +08:00
</Grid>
</Border>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Text, Mode=OneWay, RelativeSource={RelativeSource Self}}" Value="">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Placeholder" Property="Visibility" Value="Visible" />
2025-12-23 21:35:54 +08:00
</DataTrigger>
<!-- Prefix & Suffix -->
2026-02-20 15:31:44 +08:00
<Trigger SourceName="Prefix" Property="Content" Value="{x:Null}">
<Setter TargetName="Prefix" Property="Visibility" Value="Collapsed" />
2025-12-23 21:35:54 +08:00
</Trigger>
2026-02-20 15:31:44 +08:00
<Trigger SourceName="Suffix" Property="Content" Value="{x:Null}">
<Setter TargetName="Suffix" Property="Visibility" Value="Collapsed" />
2025-12-23 21:35:54 +08:00
</Trigger>
<MultiTrigger>
<!-- 可清空 -->
<MultiTrigger.Conditions>
<Condition Property="assists:InputAssist.Clearable" Value="True" />
2026-02-20 15:31:44 +08:00
<Condition SourceName="Placeholder" Property="Visibility" Value="Collapsed" />
2025-12-23 21:35:54 +08:00
</MultiTrigger.Conditions>
2026-02-20 15:31:44 +08:00
<Setter TargetName="CloseIcon" Property="Visibility" Value="Visible" />
<Setter TargetName="CloseIcon" Property="assists:InputAssist.ClearEnabled" Value="True" />
2025-12-23 21:35:54 +08:00
</MultiTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="Cursor" Value="None" />
</Trigger>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}" />
</Trigger>
<Trigger Property="IsFocused" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Prefix" Property="TextElement.Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter TargetName="Suffix" Property="TextElement.Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
2025-12-23 21:35:54 +08:00
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
2025-12-23 21:35:54 +08:00
</Trigger>
<!--<Trigger Property="IsKeyboardFocused" Value="True" />-->
</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>
2025-08-20 12:10:13 +08:00
<!-- 默认文本框样式 -->
2025-10-10 11:19:58 +08:00
<Style BasedOn="{StaticResource DefaultTextBoxStyle}" TargetType="{x:Type TextBox}" />
2025-12-23 21:35:54 +08:00
2025-08-20 12:10:13 +08:00
<!-- 富文本样式 -->
2026-02-20 15:31:44 +08:00
<Style x:Key="SlotRichTextBoxStyle" TargetType="{x:Type RichTextBox}">
2025-08-20 12:10:13 +08:00
<Style.Resources>
2026-02-20 15:31:44 +08:00
<Style x:Key="{x:Type FlowDocument}" TargetType="{x:Type FlowDocument}">
2025-08-20 12:10:13 +08:00
<Setter Property="OverridesDefaultStyle" Value="True" />
</Style>
<Style
2026-02-20 15:31:44 +08:00
x:Key="{x:Type Hyperlink}"
2025-08-20 12:10:13 +08:00
BasedOn="{StaticResource {x:Type Hyperlink}}"
2026-02-20 15:31:44 +08:00
TargetType="{x:Type Hyperlink}">
2025-08-20 12:10:13 +08:00
<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>
2025-08-26 21:33:20 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-20 12:10:13 +08:00
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontSize" Value="14" />
<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
Storyboard.TargetName="slot"
Storyboard.TargetProperty="Intensity"
2026-02-20 15:31:44 +08:00
To="0.5"
Duration="0:0:0.2" />
2025-08-20 12:10:13 +08:00
</Storyboard>
<!-- 取消聚焦对象 -->
<Storyboard x:Key="TextBox.LeaveEffect">
<DoubleAnimation
Storyboard.TargetName="slot"
Storyboard.TargetProperty="Intensity"
2026-02-20 15:31:44 +08:00
To="0.2"
Duration="0:0:0.2" />
2025-08-20 12:10:13 +08:00
</Storyboard>
</ControlTemplate.Resources>
<decorations:SlotBorder
2026-02-20 15:31:44 +08:00
x:Name="slot"
Padding="{TemplateBinding Padding}"
2025-08-20 12:10:13 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Intensity="0.2"
2026-02-20 15:31:44 +08:00
SnapsToDevicePixels="True">
2025-09-04 22:39:00 +08:00
<!-- Margin="{Binding Padding, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:ThicknessReverseConverter.Instance}}" -->
2025-08-20 12:10:13 +08:00
<ScrollViewer
2026-02-20 15:31:44 +08:00
x:Name="PART_ContentHost"
2025-08-20 12:10:13 +08:00
Background="{x:Null}"
BorderThickness="0"
Focusable="False"
HorizontalScrollBarVisibility="Hidden"
IsTabStop="False"
2026-02-20 15:31:44 +08:00
VerticalScrollBarVisibility="Hidden" />
</decorations:SlotBorder>
2025-08-20 12:10:13 +08:00
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
2026-02-20 15:31:44 +08:00
<Setter TargetName="slot" Property="ShaderEnabled" Value="False" />
2025-08-20 12:10:13 +08:00
</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>
2025-12-23 21:35:54 +08:00
<Style TargetType="{x:Type RichTextBox}">
<Style.Resources>
2026-02-20 15:31:44 +08:00
<Style x:Key="{x:Type FlowDocument}" TargetType="{x:Type FlowDocument}">
2025-12-23 21:35:54 +08:00
<Setter Property="OverridesDefaultStyle" Value="True" />
</Style>
<Style
2026-02-20 15:31:44 +08:00
x:Key="{x:Type Hyperlink}"
2025-12-23 21:35:54 +08:00
BasedOn="{StaticResource {x:Type Hyperlink}}"
2026-02-20 15:31:44 +08:00
TargetType="{x:Type Hyperlink}">
2025-12-23 21:35:54 +08:00
<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>
2025-08-20 12:10:13 +08:00
<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" />
2025-12-23 21:35:54 +08:00
<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}">
<Border
2026-02-20 15:31:44 +08:00
x:Name="ContentBorder"
Padding="{TemplateBinding Padding}"
2025-12-23 21:35:54 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
2026-02-20 15:31:44 +08:00
SnapsToDevicePixels="True">
2025-12-23 21:35:54 +08:00
<ScrollViewer
2026-02-20 15:31:44 +08:00
x:Name="PART_ContentHost"
2025-12-23 21:35:54 +08:00
Background="{x:Null}"
BorderThickness="0"
Focusable="False"
HorizontalScrollBarVisibility="Hidden"
IsTabStop="False"
2026-02-20 15:31:44 +08:00
VerticalScrollBarVisibility="Hidden" />
2025-12-23 21:35:54 +08:00
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="Cursor" Value="None" />
</Trigger>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="Foreground" Value="{DynamicResource TextSecondaryBrush}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
2025-12-23 21:35:54 +08:00
</Trigger>
<Trigger Property="IsFocused" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
2025-12-23 21:35:54 +08:00
</Trigger>
<!--<Trigger Property="IsMouseOver" Value="True" />-->
<!--<Trigger Property="IsKeyboardFocused" Value="True" />-->
</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>
<!-- 工具栏文本框样式 -->
2026-02-20 15:31:44 +08:00
<Style x:Key="{x:Static ToolBar.TextBoxStyleKey}" TargetType="{x:Type TextBox}">
2025-12-23 21:35:54 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontSize" Value="14" />
2025-08-20 12:10:13 +08:00
<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
2026-02-20 15:31:44 +08:00
x:Name="border"
2025-08-20 12:10:13 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
2026-02-20 15:31:44 +08:00
SnapsToDevicePixels="True">
2025-08-20 12:10:13 +08:00
<ScrollViewer
2026-02-20 15:31:44 +08:00
x:Name="PART_ContentHost"
2025-08-20 12:10:13 +08:00
Focusable="False"
HorizontalScrollBarVisibility="Hidden"
2026-02-20 15:31:44 +08:00
VerticalScrollBarVisibility="Hidden" />
2025-08-20 12:10:13 +08:00
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
2026-02-20 15:31:44 +08:00
<Setter TargetName="PART_ContentHost" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
2025-08-20 12:10:13 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
2025-08-20 12:10:13 +08:00
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
2025-08-20 12:10:13 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>