324 lines
22 KiB
XML
324 lines
22 KiB
XML
<ResourceDictionary
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:controls="clr-namespace:WPFluent.Controls"
|
|
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
<ResourceDictionary.MergedDictionaries>
|
|
<ResourceDictionary Source="/WPFluent;component/Resources/Variables.xaml" />
|
|
</ResourceDictionary.MergedDictionaries>
|
|
<Thickness x:Key="PasswordBoxBorderThemeThickness">1,1,1,1</Thickness>
|
|
<Thickness x:Key="PasswordBoxAccentBorderThemeThickness">0,0,0,1</Thickness>
|
|
<Thickness x:Key="PasswordBoxLeftIconMargin">10,8,0,0</Thickness>
|
|
<Thickness x:Key="PasswordBoxRightIconMargin">0,8,10,0</Thickness>
|
|
<Thickness x:Key="PasswordBoxButtonMargin">0,5,4,0</Thickness>
|
|
<Thickness x:Key="PasswordBoxButtonPadding">0,0,0,0</Thickness>
|
|
<system:Double x:Key="PasswordBoxButtonHeight">24</system:Double>
|
|
<system:Double x:Key="PasswordBoxButtonIconSize">14</system:Double>
|
|
|
|
<ContextMenu x:Key="DefaultPasswordBoxContextMenu">
|
|
<MenuItem Command="ApplicationCommands.Paste" />
|
|
</ContextMenu>
|
|
|
|
<Style TargetType="{x:Type PasswordBox}" x:Key="DefaultPasswordBoxStyle">
|
|
<!-- Universal WPF UI focus -->
|
|
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
|
|
<!-- Universal WPF UI focus -->
|
|
<!-- Universal WPF UI ContextMenu -->
|
|
<Setter Property="ContextMenu" Value="{DynamicResource DefaultPasswordBoxContextMenu}" />
|
|
<!-- Universal WPF UI ContextMenu -->
|
|
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
|
|
<Setter Property="CaretBrush" Value="{DynamicResource TextFillColorPrimaryBrush}" />
|
|
<Setter Property="Background" Value="{DynamicResource ControlFillColorDefaultBrush}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource TextControlElevationBorderBrush}" />
|
|
<Setter Property="BorderThickness" Value="{StaticResource PasswordBoxBorderThemeThickness}" />
|
|
<Setter Property="FontSize" Value="{StaticResource ControlContentThemeFontSize}" />
|
|
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
|
<Setter Property="VerticalAlignment" Value="Center" />
|
|
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
|
<Setter Property="VerticalContentAlignment" Value="Top" />
|
|
<Setter Property="MinHeight" Value="{StaticResource TextControlThemeMinHeight}" />
|
|
<Setter Property="MinWidth" Value="{StaticResource TextControlThemeMinWidth}" />
|
|
<Setter Property="Padding" Value="{StaticResource TextControlThemePadding}" />
|
|
<Setter Property="Border.CornerRadius" Value="{StaticResource ControlCornerRadius}" />
|
|
<Setter Property="SnapsToDevicePixels" Value="True" />
|
|
<Setter Property="OverridesDefaultStyle" Value="True" />
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type PasswordBox}">
|
|
<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
|
|
<Border
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="{TemplateBinding Border.CornerRadius}"
|
|
HorizontalAlignment="Stretch"
|
|
MinHeight="{TemplateBinding MinHeight}"
|
|
MinWidth="{TemplateBinding MinWidth}"
|
|
Padding="0"
|
|
VerticalAlignment="Stretch"
|
|
x:Name="ContentBorder">
|
|
<Grid
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
Margin="{TemplateBinding Padding}"
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
|
|
<controls:PassiveScrollViewer
|
|
Style="{DynamicResource DefaultTextBoxScrollViewerStyle}"
|
|
TextElement.Foreground="{TemplateBinding Foreground}"
|
|
x:Name="PART_ContentHost" />
|
|
</Grid>
|
|
</Border>
|
|
<!-- The Accent Border is a separate element so that changes to the border thickness do not affect the position of the element -->
|
|
<Border
|
|
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
|
|
BorderThickness="{StaticResource PasswordBoxAccentBorderThemeThickness}"
|
|
CornerRadius="{TemplateBinding Border.CornerRadius}"
|
|
HorizontalAlignment="Stretch"
|
|
VerticalAlignment="Stretch"
|
|
x:Name="AccentBorder" />
|
|
</Grid>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="IsFocused" Value="True">
|
|
<Setter Property="BorderThickness" TargetName="AccentBorder" Value="0,0,0,2" />
|
|
<Setter Property="BorderBrush" TargetName="AccentBorder" Value="{DynamicResource SystemFillColorAttentionBrush}" />
|
|
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlFillColorInputActiveBrush}" />
|
|
</Trigger>
|
|
<MultiTrigger>
|
|
<MultiTrigger.Conditions>
|
|
<Condition Property="IsEnabled" Value="True" />
|
|
<Condition Property="IsMouseOver" Value="True" />
|
|
<Condition Property="IsFocused" Value="False" />
|
|
</MultiTrigger.Conditions>
|
|
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlFillColorSecondaryBrush}" />
|
|
</MultiTrigger>
|
|
<Trigger Property="IsEnabled" Value="True">
|
|
<Setter Property="Cursor" Value="IBeam" />
|
|
</Trigger>
|
|
<Trigger Property="IsEnabled" Value="False">
|
|
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlFillColorDisabledBrush}" />
|
|
<Setter Property="BorderBrush" TargetName="ContentBorder" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
|
|
<Setter Property="BorderBrush" TargetName="AccentBorder" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
|
|
<Setter Property="Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
|
|
</Trigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
|
|
<Style TargetType="{x:Type controls:PasswordBox}" x:Key="DefaultUiPasswordBoxStyle">
|
|
<!-- Universal WPF UI focus -->
|
|
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
|
|
<!-- Universal WPF UI focus -->
|
|
<!-- Universal WPF UI ContextMenu -->
|
|
<Setter Property="ContextMenu" Value="{DynamicResource DefaultPasswordBoxContextMenu}" />
|
|
<!-- Universal WPF UI ContextMenu -->
|
|
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
|
|
<Setter Property="CaretBrush" Value="{DynamicResource TextFillColorPrimaryBrush}" />
|
|
<Setter Property="Background" Value="{DynamicResource ControlFillColorDefaultBrush}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource TextControlElevationBorderBrush}" />
|
|
<Setter Property="BorderThickness" Value="{StaticResource PasswordBoxBorderThemeThickness}" />
|
|
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
|
|
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
|
<Setter Property="VerticalAlignment" Value="Center" />
|
|
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
|
<Setter Property="VerticalContentAlignment" Value="Top" />
|
|
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
|
|
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
|
|
<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
|
|
<Setter Property="Border.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
|
|
<Setter Property="ClearButtonEnabled" Value="True" />
|
|
<Setter Property="RevealButtonEnabled" Value="True" />
|
|
<Setter Property="IconPlacement" Value="Left" />
|
|
<Setter Property="SnapsToDevicePixels" Value="True" />
|
|
<Setter Property="OverridesDefaultStyle" Value="True" />
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type controls:PasswordBox}">
|
|
<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
|
|
<Border
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="{TemplateBinding Border.CornerRadius}"
|
|
HorizontalAlignment="Stretch"
|
|
MinHeight="{TemplateBinding MinHeight}"
|
|
MinWidth="{TemplateBinding MinWidth}"
|
|
Padding="0"
|
|
VerticalAlignment="Stretch"
|
|
x:Name="ContentBorder">
|
|
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="*" />
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="Auto" />
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<ContentPresenter
|
|
Content="{TemplateBinding Icon}"
|
|
Grid.Column="0"
|
|
Margin="{StaticResource PasswordBoxLeftIconMargin}"
|
|
TextElement.FontSize="16"
|
|
TextElement.Foreground="{TemplateBinding Foreground}"
|
|
VerticalAlignment="Top"
|
|
x:Name="ControlIconLeft" />
|
|
|
|
<Grid Grid.Column="1" Margin="{TemplateBinding Padding}">
|
|
<controls:PassiveScrollViewer
|
|
Style="{DynamicResource DefaultTextBoxScrollViewerStyle}"
|
|
TextElement.Foreground="{TemplateBinding Foreground}"
|
|
x:Name="PART_ContentHost" />
|
|
<TextBlock
|
|
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
|
Margin="0"
|
|
Padding="1,0"
|
|
Text="{TemplateBinding PlaceholderText}"
|
|
VerticalAlignment="Top"
|
|
x:Name="PlaceholderTextBox" />
|
|
</Grid>
|
|
|
|
<!-- 按钮和图标与主元素之间没有填充,以便在高度大于文本输入区时允许绝对定位 -->
|
|
<controls:Button
|
|
Appearance="Primary"
|
|
Background="Transparent"
|
|
BorderBrush="Transparent"
|
|
Command="{Binding Path=TemplateButtonCommand, RelativeSource={RelativeSource TemplatedParent}}"
|
|
CommandParameter="clear"
|
|
Cursor="Arrow"
|
|
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
|
Grid.Column="2"
|
|
Height="{StaticResource PasswordBoxButtonHeight}"
|
|
HorizontalAlignment="Center"
|
|
HorizontalContentAlignment="Center"
|
|
IsTabStop="False"
|
|
Margin="{StaticResource PasswordBoxButtonMargin}"
|
|
Padding="{StaticResource PasswordBoxButtonPadding}"
|
|
VerticalAlignment="Top"
|
|
VerticalContentAlignment="Center"
|
|
Width="{StaticResource PasswordBoxButtonHeight}"
|
|
x:Name="ClearButton">
|
|
<controls:Button.Icon>
|
|
<controls:SymbolIcon FontSize="{StaticResource PasswordBoxButtonIconSize}" Symbol="Dismiss24" />
|
|
</controls:Button.Icon>
|
|
</controls:Button>
|
|
|
|
<controls:Button
|
|
Appearance="Primary"
|
|
Background="Transparent"
|
|
BorderBrush="Transparent"
|
|
Command="{Binding Path=TemplateButtonCommand, RelativeSource={RelativeSource TemplatedParent}}"
|
|
CommandParameter="reveal"
|
|
Cursor="Arrow"
|
|
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
|
Grid.Column="3"
|
|
Height="{StaticResource PasswordBoxButtonHeight}"
|
|
HorizontalAlignment="Center"
|
|
HorizontalContentAlignment="Center"
|
|
IsTabStop="False"
|
|
Margin="{StaticResource PasswordBoxButtonMargin}"
|
|
Padding="{StaticResource PasswordBoxButtonPadding}"
|
|
VerticalAlignment="Top"
|
|
VerticalContentAlignment="Center"
|
|
Width="{StaticResource PasswordBoxButtonHeight}"
|
|
x:Name="RevealButton">
|
|
<controls:Button.Icon>
|
|
<controls:SymbolIcon FontSize="{StaticResource PasswordBoxButtonIconSize}" Symbol="Eye24" />
|
|
</controls:Button.Icon>
|
|
</controls:Button>
|
|
|
|
<ContentPresenter
|
|
Content="{TemplateBinding Icon}"
|
|
Grid.Column="4"
|
|
Margin="{StaticResource PasswordBoxRightIconMargin}"
|
|
TextElement.FontSize="16"
|
|
TextElement.Foreground="{TemplateBinding Foreground}"
|
|
VerticalAlignment="Top"
|
|
x:Name="ControlIconRight" />
|
|
</Grid>
|
|
</Border>
|
|
|
|
<!-- The Accent Border is a separate element so that changes to the border thickness do not affect the position of the element -->
|
|
<Border
|
|
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
|
|
BorderThickness="{StaticResource PasswordBoxAccentBorderThemeThickness}"
|
|
CornerRadius="{TemplateBinding Border.CornerRadius}"
|
|
HorizontalAlignment="Stretch"
|
|
VerticalAlignment="Stretch"
|
|
x:Name="AccentBorder" />
|
|
</Grid>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="CurrentPlaceholderEnabled" Value="False">
|
|
<Setter Property="Visibility" TargetName="PlaceholderTextBox" Value="Collapsed" />
|
|
</Trigger>
|
|
<Trigger Property="ShowClearButton" Value="False">
|
|
<Setter Property="Visibility" TargetName="ClearButton" Value="Collapsed" />
|
|
<Setter Property="Margin" TargetName="ClearButton" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="ClearButtonEnabled" Value="False">
|
|
<Setter Property="Visibility" TargetName="ClearButton" Value="Collapsed" />
|
|
<Setter Property="Margin" TargetName="ClearButton" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="RevealButtonEnabled" Value="False">
|
|
<Setter Property="Visibility" TargetName="RevealButton" Value="Collapsed" />
|
|
<Setter Property="Margin" TargetName="RevealButton" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="IsPasswordRevealed" Value="True">
|
|
<Setter Property="Icon" TargetName="RevealButton">
|
|
<Setter.Value>
|
|
<controls:SymbolIcon Symbol="EyeOff24" />
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Trigger>
|
|
<Trigger Property="IconPlacement" Value="Left">
|
|
<Setter Property="Visibility" TargetName="ControlIconRight" Value="Collapsed" />
|
|
<Setter Property="Margin" TargetName="ControlIconRight" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="IconPlacement" Value="Right">
|
|
<Setter Property="Visibility" TargetName="ControlIconLeft" Value="Collapsed" />
|
|
<Setter Property="Margin" TargetName="ControlIconLeft" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="Icon" Value="{x:Null}">
|
|
<Setter Property="Visibility" TargetName="ControlIconRight" Value="Collapsed" />
|
|
<Setter Property="Margin" TargetName="ControlIconRight" Value="0" />
|
|
<Setter Property="Visibility" TargetName="ControlIconLeft" Value="Collapsed" />
|
|
<Setter Property="Margin" TargetName="ControlIconLeft" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="IsFocused" Value="True">
|
|
<Setter Property="BorderThickness" TargetName="AccentBorder" Value="0,0,0,2" />
|
|
<Setter Property="BorderBrush" TargetName="AccentBorder" Value="{DynamicResource SystemFillColorAttentionBrush}" />
|
|
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlFillColorInputActiveBrush}" />
|
|
</Trigger>
|
|
<MultiTrigger>
|
|
<MultiTrigger.Conditions>
|
|
<Condition Property="IsEnabled" Value="True" />
|
|
<Condition Property="IsMouseOver" Value="True" />
|
|
<Condition Property="IsFocused" Value="False" />
|
|
</MultiTrigger.Conditions>
|
|
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlFillColorSecondaryBrush}" />
|
|
</MultiTrigger>
|
|
<Trigger Property="IsEnabled" Value="True">
|
|
<Setter Property="Cursor" Value="IBeam" />
|
|
</Trigger>
|
|
<Trigger Property="IsEnabled" Value="False">
|
|
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlFillColorDisabledBrush}" />
|
|
<Setter Property="BorderBrush" TargetName="ContentBorder" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
|
|
<Setter Property="BorderBrush" TargetName="AccentBorder" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
|
|
<Setter Property="TextElement.Foreground" TargetName="ControlIconLeft" Value="{DynamicResource TextFillColorDisabledBrush}" />
|
|
<Setter Property="TextElement.Foreground" TargetName="ControlIconRight" Value="{DynamicResource TextFillColorDisabledBrush}" />
|
|
<Setter Property="Foreground" TargetName="PlaceholderTextBox" Value="{DynamicResource TextFillColorDisabledBrush}" />
|
|
<Setter Property="Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
|
|
<Setter Property="ClearButtonEnabled" Value="False" />
|
|
<Setter Property="RevealButtonEnabled" Value="False" />
|
|
</Trigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
|
|
<Style BasedOn="{StaticResource DefaultPasswordBoxStyle}" TargetType="{x:Type PasswordBox}" />
|
|
<Style BasedOn="{StaticResource DefaultUiPasswordBoxStyle}" TargetType="{x:Type controls:PasswordBox}" />
|
|
|
|
</ResourceDictionary>
|