332 lines
22 KiB
XML
332 lines
22 KiB
XML
<!--
|
|
This Source Code Form is subject to the terms of the MIT License.
|
|
If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
|
|
Copyright (C) Leszek Pomianowski and WPF UI Contributors.
|
|
All Rights Reserved.
|
|
|
|
Based on Microsoft XAML for Win UI
|
|
Copyright (c) Microsoft Corporation. All Rights Reserved.
|
|
-->
|
|
|
|
<ResourceDictionary
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:controls="clr-namespace:WPFluent.Controls"
|
|
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
|
|
|
<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 x:Key="DefaultPasswordBoxStyle" TargetType="{x:Type PasswordBox}">
|
|
<!-- 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 TextControlForeground}" />
|
|
<Setter Property="CaretBrush" Value="{DynamicResource TextControlForeground}" />
|
|
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
|
|
<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="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
|
|
x:Name="ContentBorder"
|
|
MinWidth="{TemplateBinding MinWidth}"
|
|
MinHeight="{TemplateBinding MinHeight}"
|
|
Padding="0"
|
|
HorizontalAlignment="Stretch"
|
|
VerticalAlignment="Stretch"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="{TemplateBinding Border.CornerRadius}">
|
|
<Grid
|
|
Margin="{TemplateBinding Padding}"
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
|
|
<controls:PassiveScrollViewer
|
|
x:Name="PART_ContentHost"
|
|
Style="{DynamicResource DefaultTextBoxScrollViewerStyle}"
|
|
TextElement.Foreground="{TemplateBinding Foreground}" />
|
|
</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
|
|
x:Name="AccentBorder"
|
|
HorizontalAlignment="Stretch"
|
|
VerticalAlignment="Stretch"
|
|
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
|
|
BorderThickness="{StaticResource PasswordBoxAccentBorderThemeThickness}"
|
|
CornerRadius="{TemplateBinding Border.CornerRadius}" />
|
|
</Grid>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="IsFocused" Value="True">
|
|
<Setter TargetName="AccentBorder" Property="BorderThickness" Value="0,0,0,2" />
|
|
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource TextControlFocusedBorderBrush}" />
|
|
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundFocused}" />
|
|
</Trigger>
|
|
<MultiTrigger>
|
|
<MultiTrigger.Conditions>
|
|
<Condition Property="IsEnabled" Value="True" />
|
|
<Condition Property="IsMouseOver" Value="True" />
|
|
<Condition Property="IsFocused" Value="False" />
|
|
</MultiTrigger.Conditions>
|
|
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundPointerOver}" />
|
|
</MultiTrigger>
|
|
<Trigger Property="IsEnabled" Value="True">
|
|
<Setter Property="Cursor" Value="IBeam" />
|
|
</Trigger>
|
|
<Trigger Property="IsEnabled" Value="False">
|
|
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundDisabled}" />
|
|
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
|
|
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
|
|
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
|
|
</Trigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
|
|
<Style x:Key="DefaultUiPasswordBoxStyle" TargetType="{x:Type controls:PasswordBox}">
|
|
<!-- 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 TextControlForeground}" />
|
|
<Setter Property="CaretBrush" Value="{DynamicResource TextControlForeground}" />
|
|
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
|
|
<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
|
|
x:Name="ContentBorder"
|
|
MinWidth="{TemplateBinding MinWidth}"
|
|
MinHeight="{TemplateBinding MinHeight}"
|
|
Padding="0"
|
|
HorizontalAlignment="Stretch"
|
|
VerticalAlignment="Stretch"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="{TemplateBinding Border.CornerRadius}">
|
|
<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
|
|
x:Name="ControlIconLeft"
|
|
Grid.Column="0"
|
|
Margin="{StaticResource PasswordBoxLeftIconMargin}"
|
|
VerticalAlignment="Top"
|
|
Content="{TemplateBinding Icon}"
|
|
TextElement.FontSize="16"
|
|
TextElement.Foreground="{TemplateBinding Foreground}" />
|
|
|
|
<Grid Grid.Column="1" Margin="{TemplateBinding Padding}">
|
|
<controls:PassiveScrollViewer
|
|
x:Name="PART_ContentHost"
|
|
Style="{DynamicResource DefaultTextBoxScrollViewerStyle}"
|
|
TextElement.Foreground="{TemplateBinding Foreground}" />
|
|
<TextBlock
|
|
x:Name="PlaceholderTextBox"
|
|
Margin="0"
|
|
Padding="1,0"
|
|
VerticalAlignment="Top"
|
|
Foreground="{DynamicResource TextControlPlaceholderForeground}"
|
|
Text="{TemplateBinding PlaceholderText}" />
|
|
</Grid>
|
|
|
|
<!-- Buttons and Icons have no padding from the main element to allow absolute positions if height is larger than the text entry zone -->
|
|
<controls:Button
|
|
x:Name="ClearButton"
|
|
Grid.Column="2"
|
|
Width="{StaticResource PasswordBoxButtonHeight}"
|
|
Height="{StaticResource PasswordBoxButtonHeight}"
|
|
Margin="{StaticResource PasswordBoxButtonMargin}"
|
|
Padding="{StaticResource PasswordBoxButtonPadding}"
|
|
HorizontalAlignment="Center"
|
|
VerticalAlignment="Top"
|
|
HorizontalContentAlignment="Center"
|
|
VerticalContentAlignment="Center"
|
|
Appearance="Secondary"
|
|
Background="Transparent"
|
|
BorderBrush="Transparent"
|
|
Command="{Binding Path=TemplateButtonCommand, RelativeSource={RelativeSource TemplatedParent}}"
|
|
CommandParameter="clear"
|
|
Cursor="Arrow"
|
|
Foreground="{DynamicResource TextControlButtonForeground}"
|
|
IsTabStop="False">
|
|
<controls:Button.Icon>
|
|
<controls:SymbolIcon FontSize="{StaticResource PasswordBoxButtonIconSize}" Symbol="Dismiss24" />
|
|
</controls:Button.Icon>
|
|
</controls:Button>
|
|
|
|
<controls:Button
|
|
x:Name="RevealButton"
|
|
Grid.Column="3"
|
|
Width="{StaticResource PasswordBoxButtonHeight}"
|
|
Height="{StaticResource PasswordBoxButtonHeight}"
|
|
Margin="{StaticResource PasswordBoxButtonMargin}"
|
|
Padding="{StaticResource PasswordBoxButtonPadding}"
|
|
HorizontalAlignment="Center"
|
|
VerticalAlignment="Top"
|
|
HorizontalContentAlignment="Center"
|
|
VerticalContentAlignment="Center"
|
|
Appearance="Secondary"
|
|
Background="Transparent"
|
|
BorderBrush="Transparent"
|
|
Command="{Binding Path=TemplateButtonCommand, RelativeSource={RelativeSource TemplatedParent}}"
|
|
CommandParameter="reveal"
|
|
Cursor="Arrow"
|
|
Foreground="{DynamicResource TextControlButtonForeground}"
|
|
IsTabStop="False">
|
|
<controls:Button.Icon>
|
|
<controls:SymbolIcon FontSize="{StaticResource PasswordBoxButtonIconSize}" Symbol="Eye24" />
|
|
</controls:Button.Icon>
|
|
</controls:Button>
|
|
|
|
<ContentPresenter
|
|
x:Name="ControlIconRight"
|
|
Grid.Column="4"
|
|
Margin="{StaticResource PasswordBoxRightIconMargin}"
|
|
VerticalAlignment="Top"
|
|
Content="{TemplateBinding Icon}"
|
|
TextElement.FontSize="16"
|
|
TextElement.Foreground="{TemplateBinding Foreground}" />
|
|
</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
|
|
x:Name="AccentBorder"
|
|
HorizontalAlignment="Stretch"
|
|
VerticalAlignment="Stretch"
|
|
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
|
|
BorderThickness="{StaticResource PasswordBoxAccentBorderThemeThickness}"
|
|
CornerRadius="{TemplateBinding Border.CornerRadius}" />
|
|
</Grid>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="CurrentPlaceholderEnabled" Value="False">
|
|
<Setter TargetName="PlaceholderTextBox" Property="Visibility" Value="Collapsed" />
|
|
</Trigger>
|
|
<Trigger Property="ShowClearButton" Value="False">
|
|
<Setter TargetName="ClearButton" Property="Visibility" Value="Collapsed" />
|
|
<Setter TargetName="ClearButton" Property="Margin" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="ClearButtonEnabled" Value="False">
|
|
<Setter TargetName="ClearButton" Property="Visibility" Value="Collapsed" />
|
|
<Setter TargetName="ClearButton" Property="Margin" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="RevealButtonEnabled" Value="False">
|
|
<Setter TargetName="RevealButton" Property="Visibility" Value="Collapsed" />
|
|
<Setter TargetName="RevealButton" Property="Margin" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="IsPasswordRevealed" Value="True">
|
|
<Setter TargetName="RevealButton" Property="Icon">
|
|
<Setter.Value>
|
|
<controls:SymbolIcon Symbol="EyeOff24" />
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Trigger>
|
|
<Trigger Property="IconPlacement" Value="Left">
|
|
<Setter TargetName="ControlIconRight" Property="Visibility" Value="Collapsed" />
|
|
<Setter TargetName="ControlIconRight" Property="Margin" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="IconPlacement" Value="Right">
|
|
<Setter TargetName="ControlIconLeft" Property="Visibility" Value="Collapsed" />
|
|
<Setter TargetName="ControlIconLeft" Property="Margin" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="Icon" Value="{x:Null}">
|
|
<Setter TargetName="ControlIconRight" Property="Visibility" Value="Collapsed" />
|
|
<Setter TargetName="ControlIconRight" Property="Margin" Value="0" />
|
|
<Setter TargetName="ControlIconLeft" Property="Visibility" Value="Collapsed" />
|
|
<Setter TargetName="ControlIconLeft" Property="Margin" Value="0" />
|
|
</Trigger>
|
|
<Trigger Property="IsFocused" Value="True">
|
|
<Setter TargetName="AccentBorder" Property="BorderThickness" Value="0,0,0,2" />
|
|
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource TextControlFocusedBorderBrush}" />
|
|
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundFocused}" />
|
|
</Trigger>
|
|
<MultiTrigger>
|
|
<MultiTrigger.Conditions>
|
|
<Condition Property="IsEnabled" Value="True" />
|
|
<Condition Property="IsMouseOver" Value="True" />
|
|
<Condition Property="IsFocused" Value="False" />
|
|
</MultiTrigger.Conditions>
|
|
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundPointerOver}" />
|
|
</MultiTrigger>
|
|
<Trigger Property="IsEnabled" Value="True">
|
|
<Setter Property="Cursor" Value="IBeam" />
|
|
</Trigger>
|
|
<Trigger Property="IsEnabled" Value="False">
|
|
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundDisabled}" />
|
|
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
|
|
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
|
|
<Setter TargetName="ControlIconLeft" Property="TextElement.Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
|
|
<Setter TargetName="ControlIconRight" Property="TextElement.Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
|
|
<Setter TargetName="PlaceholderTextBox" Property="Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
|
|
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
|
|
<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>
|