功能更新
This commit is contained in:
542
Melskin/Controls/PasswordBox.xaml
Normal file
542
Melskin/Controls/PasswordBox.xaml
Normal file
@@ -0,0 +1,542 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:assists="clr-namespace:Melskin.Assists"
|
||||
xmlns:controls="clr-namespace:Melskin.Controls"
|
||||
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/Melskin;component/Themes/Animations.xaml" />
|
||||
<ResourceDictionary Source="/Melskin;component/Controls/IconElement.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<ControlTemplate TargetType="{x:Type PasswordBox}" x:Key="SlotPasswordBoxTemplate">
|
||||
<decorations:SlotBorder
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Intensity="0.2"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="True"
|
||||
x:Name="slot">
|
||||
<Grid>
|
||||
<TextBlock
|
||||
Focusable="False"
|
||||
Foreground="{DynamicResource TextPlaceholderBrush}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Margin="5,0,0,0"
|
||||
Text="{TemplateBinding assists:InputAssist.PlaceholderText}"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="Collapsed"
|
||||
x:Name="Placeholder" />
|
||||
<ScrollViewer
|
||||
Focusable="False"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Hidden"
|
||||
x:Name="PART_ContentHost" />
|
||||
</Grid>
|
||||
</decorations:SlotBorder>
|
||||
|
||||
<ControlTemplate.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>
|
||||
<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="assists:InputAssist.HasPassword" Value="False">
|
||||
<Setter Property="Visibility" TargetName="Placeholder" Value="Visible" />
|
||||
</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>
|
||||
<ControlTemplate TargetType="{x:Type PasswordBox}" x:Key="SlotPasswordBoxEyeableTemplate">
|
||||
<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>
|
||||
<decorations:SlotBorder
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Intensity="0.2"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="True"
|
||||
UseLayoutRounding="True"
|
||||
x:Name="slot">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<!-- Prefix -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<!-- Input -->
|
||||
<ColumnDefinition Width="*" />
|
||||
<!-- Clear -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<!-- Eye -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Prefix -->
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding assists:InputAssist.Prefix}"
|
||||
Focusable="False"
|
||||
Grid.Column="0"
|
||||
Margin="1,0,5,0"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="Prefix" />
|
||||
<!-- Placeholder -->
|
||||
<TextBlock
|
||||
Focusable="False"
|
||||
Foreground="{DynamicResource TextPlaceholderBrush}"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Margin="5,0,0,0"
|
||||
Text="{TemplateBinding assists:InputAssist.PlaceholderText}"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="Collapsed"
|
||||
x:Name="Placeholder" />
|
||||
<!-- Input -->
|
||||
<!-- ScrollViewer will automatically handle padding, so you need to change the margin to a negative value. -->
|
||||
<ScrollViewer
|
||||
Background="{x:Null}"
|
||||
BorderThickness="0"
|
||||
Grid.Column="1"
|
||||
IsTabStop="False"
|
||||
x:Name="PART_ContentHost" />
|
||||
<!-- Password Text Box -->
|
||||
<TextBox
|
||||
Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"
|
||||
Grid.Column="1"
|
||||
IsTabStop="False"
|
||||
Style="{DynamicResource FlattenTextBoxStyle}"
|
||||
Text="{Binding Path=(assists:InputAssist.Password), Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
|
||||
Visibility="Collapsed"
|
||||
x:Name="PART_TextBox" />
|
||||
<!-- 清空按钮 -->
|
||||
<controls:IconElement
|
||||
Grid.Column="2"
|
||||
Style="{DynamicResource ToolIcon}"
|
||||
Symbol="Close"
|
||||
Visibility="Collapsed"
|
||||
x:Name="CloseIcon" />
|
||||
<!-- Eye -->
|
||||
<ToggleButton
|
||||
Grid.Column="3"
|
||||
IsHitTestVisible="True"
|
||||
IsTabStop="False"
|
||||
Margin="5,0,1,0"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Visibility="Collapsed"
|
||||
x:Name="PART_Eye">
|
||||
<ToggleButton.Style>
|
||||
<Style TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Opacity" Value="0.65" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<!--<controls:IconElement
|
||||
Style="{DynamicResource ToolIcon}"
|
||||
Symbol="Password2Off"
|
||||
x:Name="Icon" />
|
||||
<ControlTemplate.Triggers>
|
||||
-->
|
||||
<!--<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Opacity" Value="0.85" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Opacity" Value="1" />
|
||||
</Trigger>-->
|
||||
<!--
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="Opacity" Value="1" />
|
||||
<Setter Property="Symbol" TargetName="Icon" Value="Password2" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>-->
|
||||
<controls:IconElement
|
||||
Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=ToggleButton}}"
|
||||
VerticalAlignment="Center"
|
||||
x:Name="EyeIcon">
|
||||
<controls:IconElement.Style>
|
||||
<Style BasedOn="{StaticResource IconElementStyle}" TargetType="{x:Type controls:IconElement}">
|
||||
<Setter Property="Symbol" Value="Visibility" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource AncestorType=ToggleButton}}" Value="True">
|
||||
<Setter Property="Symbol" Value="VisibilityOff" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</controls:IconElement.Style>
|
||||
</controls:IconElement>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="Opacity" Value="1" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ToggleButton.Style>
|
||||
</ToggleButton>
|
||||
|
||||
</Grid>
|
||||
</decorations:SlotBorder>
|
||||
</Grid>
|
||||
<ControlTemplate.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>
|
||||
<Trigger Property="assists:InputAssist.HasPassword" Value="False">
|
||||
<Setter Property="Visibility" TargetName="Placeholder" Value="Visible" />
|
||||
</Trigger>
|
||||
<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>
|
||||
<!-- Prefix -->
|
||||
<Trigger Property="Content" SourceName="Prefix" Value="{x:Null}">
|
||||
<Setter Property="Visibility" TargetName="Prefix" Value="Collapsed" />
|
||||
</Trigger>
|
||||
<Trigger Property="Visibility" SourceName="Placeholder" Value="Collapsed">
|
||||
<Setter Property="Visibility" TargetName="PART_Eye" Value="Visible" />
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<!-- 可清空 -->
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="assists:InputAssist.Clearable" Value="True" />
|
||||
<Condition Property="assists:InputAssist.HasPassword" Value="True" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Visibility" TargetName="CloseIcon" Value="Visible" />
|
||||
<Setter Property="assists:InputAssist.ClearEnabled" TargetName="CloseIcon" Value="True" />
|
||||
</MultiTrigger>
|
||||
<!--<Trigger SourceName="PART_TextBox" Property="IsFocused" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>-->
|
||||
<Trigger Property="IsChecked" SourceName="PART_Eye" Value="True">
|
||||
<Setter Property="Visibility" TargetName="PART_TextBox" Value="Visible" />
|
||||
<Setter Property="Visibility" TargetName="PART_ContentHost" Value="Collapsed" />
|
||||
</Trigger>
|
||||
|
||||
<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>
|
||||
<!--<Trigger Property="IsKeyboardFocusWithin" Value="True">
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="Effect"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0.2"
|
||||
Duration="0:0:0.3" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.EnterActions>
|
||||
<Trigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="Effect"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
Duration="0:0:0.3" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.ExitActions>
|
||||
</Trigger>-->
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
<Style TargetType="PasswordBox" x:Key="SlotPasswordBoxStyle">
|
||||
<Setter Property="PasswordChar" Value="●" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="assists:InputAssist.PlaceholderText" Value="请输入密码..." />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Padding" Value="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="Template" Value="{StaticResource SlotPasswordBoxTemplate}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="assists:InputAssist.IsPasswordVisible" Value="True">
|
||||
<Setter Property="Template" Value="{StaticResource SlotPasswordBoxEyeableTemplate}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<ControlTemplate TargetType="{x:Type PasswordBox}" x:Key="PasswordBoxTemplate">
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="True"
|
||||
x:Name="Border">
|
||||
<Grid>
|
||||
<TextBlock
|
||||
Focusable="False"
|
||||
Foreground="{DynamicResource TextPlaceholderBrush}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Margin="5,0,0,0"
|
||||
Text="{TemplateBinding assists:InputAssist.PlaceholderText}"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="Collapsed"
|
||||
x:Name="Placeholder" />
|
||||
<ScrollViewer
|
||||
Focusable="False"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Hidden"
|
||||
x:Name="PART_ContentHost" />
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<ControlTemplate.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>
|
||||
<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="IsFocused" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="Border" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" TargetName="Border" Value="{DynamicResource ControlBackgroundHoverBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="assists:InputAssist.HasPassword" Value="False">
|
||||
<Setter Property="Visibility" TargetName="Placeholder" Value="Visible" />
|
||||
</Trigger>
|
||||
<!--<Trigger Property="IsKeyboardFocused" Value="True" />-->
|
||||
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
|
||||
<ControlTemplate TargetType="{x:Type PasswordBox}" x:Key="PasswordBoxEyeableTemplate">
|
||||
<Grid>
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding assists:ControlAssist.CornerRadius}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="True"
|
||||
UseLayoutRounding="True"
|
||||
x:Name="Border">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<!-- Prefix -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<!-- Input -->
|
||||
<ColumnDefinition Width="*" />
|
||||
<!-- Eye -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Prefix -->
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding assists:InputAssist.Prefix}"
|
||||
Focusable="False"
|
||||
Grid.Column="0"
|
||||
Margin="1,0,5,0"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="Prefix" />
|
||||
<!-- Placeholder -->
|
||||
<TextBlock
|
||||
Focusable="False"
|
||||
Foreground="{DynamicResource TextPlaceholderBrush}"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Margin="5,0,0,0"
|
||||
Text="{TemplateBinding assists:InputAssist.PlaceholderText}"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="Collapsed"
|
||||
x:Name="Placeholder" />
|
||||
<!-- Input -->
|
||||
<!-- ScrollViewer will automatically handle padding, so you need to change the margin to a negative value. -->
|
||||
<ScrollViewer
|
||||
Background="{x:Null}"
|
||||
BorderThickness="0"
|
||||
Grid.Column="1"
|
||||
IsTabStop="False"
|
||||
x:Name="PART_ContentHost" />
|
||||
<!-- Password Text Box -->
|
||||
<TextBox
|
||||
Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"
|
||||
Grid.Column="1"
|
||||
IsTabStop="False"
|
||||
Style="{DynamicResource FlattenTextBoxStyle}"
|
||||
Text="{Binding Path=(assists:InputAssist.Password), Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
|
||||
Visibility="Collapsed"
|
||||
x:Name="PART_TextBox" />
|
||||
<!-- Eye -->
|
||||
<ToggleButton
|
||||
Grid.Column="2"
|
||||
IsHitTestVisible="True"
|
||||
IsTabStop="False"
|
||||
Margin="5,0,1,0"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Visibility="Collapsed"
|
||||
x:Name="PART_Eye">
|
||||
<ToggleButton.Style>
|
||||
<Style TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Opacity" Value="0.65" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<controls:IconElement
|
||||
Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=ToggleButton}}"
|
||||
VerticalAlignment="Center"
|
||||
x:Name="EyeIcon">
|
||||
<controls:IconElement.Style>
|
||||
<Style BasedOn="{StaticResource IconElementStyle}" TargetType="{x:Type controls:IconElement}">
|
||||
<Setter Property="Symbol" Value="Visibility" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource AncestorType=ToggleButton}}" Value="True">
|
||||
<Setter Property="Symbol" Value="VisibilityOff" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</controls:IconElement.Style>
|
||||
</controls:IconElement>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="Opacity" Value="1" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ToggleButton.Style>
|
||||
</ToggleButton>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.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>
|
||||
<Trigger Property="assists:InputAssist.HasPassword" Value="False">
|
||||
<Setter Property="Visibility" TargetName="Placeholder" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter Property="Cursor" Value="None" />
|
||||
</Trigger>
|
||||
<!-- Prefix -->
|
||||
<Trigger Property="Content" SourceName="Prefix" Value="{x:Null}">
|
||||
<Setter Property="Visibility" TargetName="Prefix" Value="Collapsed" />
|
||||
</Trigger>
|
||||
<Trigger Property="Visibility" SourceName="Placeholder" Value="Collapsed">
|
||||
<Setter Property="Visibility" TargetName="PART_Eye" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsFocused" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="Border" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" TargetName="Border" Value="{DynamicResource ControlBackgroundHoverBrush}" />
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsChecked" SourceName="PART_Eye" Value="True">
|
||||
<Setter Property="Visibility" TargetName="PART_TextBox" Value="Visible" />
|
||||
<Setter Property="Visibility" TargetName="PART_ContentHost" Value="Collapsed" />
|
||||
</Trigger>
|
||||
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
<Style TargetType="PasswordBox">
|
||||
<Setter Property="PasswordChar" Value="●" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="assists:InputAssist.PlaceholderText" Value="请输入密码" />
|
||||
<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" />
|
||||
<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" Value="{StaticResource PasswordBoxTemplate}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="assists:InputAssist.IsPasswordVisible" Value="True">
|
||||
<Setter Property="Template" Value="{StaticResource PasswordBoxEyeableTemplate}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user