<ResourceDictionary
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:local="clr-namespace:HxUserManagement"
|
xmlns:ctrl="clr-namespace:HxUserManagement.Controls">
|
|
|
<Style x:Key="passwordToggleButtonStyle" TargetType="ToggleButton">
|
<Setter Property="Focusable" Value="False"/>
|
<Setter Property="Cursor" Value="Hand"/>
|
<Setter Property="Width" Value="24"/>
|
<Setter Property="Height" Value="24"/>
|
<Setter Property="Background" Value="White"/>
|
<Setter Property="Foreground" Value="Black"/>
|
<Setter Property="IsChecked" Value="False"/>
|
<Setter Property="Template">
|
<Setter.Value>
|
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
<Grid Background="{TemplateBinding Background}">
|
<Image x:Name="img_EyeOn" Source="pack://application:,,,/HxUserManagement;component/Assets/eyeon.png" Width="24" Height="24" Visibility="Hidden"/>
|
<Image x:Name="img_EyeOff" Source="pack://application:,,,/HxUserManagement;component/Assets/eyeoff.png" Width="24" Height="24" Visibility="Visible"/>
|
</Grid>
|
<ControlTemplate.Triggers>
|
<Trigger Property="IsChecked" Value="True">
|
<Setter TargetName="img_EyeOn" Property="Visibility" Value="Visible"/>
|
<Setter TargetName="img_EyeOff" Property="Visibility" Value="Hidden"/>
|
</Trigger>
|
<Trigger Property="IsChecked" Value="False">
|
<Setter TargetName="img_EyeOn" Property="Visibility" Value="Hidden"/>
|
<Setter TargetName="img_EyeOff" Property="Visibility" Value="Visible"/>
|
</Trigger>
|
</ControlTemplate.Triggers>
|
</ControlTemplate>
|
</Setter.Value>
|
</Setter>
|
</Style>
|
|
<Style x:Key="textBoxStyle" TargetType="TextBox">
|
<Setter Property="Template">
|
<Setter.Value>
|
<ControlTemplate >
|
<Grid>
|
<Border x:Name="BackBorder" SnapsToDevicePixels="true" Background="{TemplateBinding Background}"
|
BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
|
<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
</Border>
|
</Grid>
|
<ControlTemplate.Triggers>
|
<Trigger Property="IsFocused" Value="True" >
|
<Setter Property="Background" TargetName="BackBorder" Value="White"/>
|
</Trigger>
|
<Trigger Property="IsEnabled" Value="False">
|
<Setter Property="TextBox.Foreground" Value="Gray"/>
|
</Trigger>
|
</ControlTemplate.Triggers>
|
</ControlTemplate>
|
</Setter.Value>
|
</Setter>
|
</Style>
|
|
<Style TargetType="{x:Type ctrl:HxPasswordBox}">
|
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Foreground" Value="Black"/>
|
<Setter Property="Margin" Value="5"/>
|
<Setter Property="FontSize" Value="16"/>
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
<Setter Property="HorizontalContentAlignment" Value="Left"/>
|
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
<Setter Property="BorderThickness" Value="1"/>
|
<Setter Property="BorderBrush" Value="DarkGray"/>
|
<Setter Property="Padding" Value="5,2"/>
|
<Setter Property="PasswrodChar" Value="*"/>
|
<!--<Setter Property="ShowWaterMark" Value="True"/>
|
<Setter Property="WaterMark" Value="Pin"/>-->
|
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
<Setter Property="AllowDrop" Value="True"/>
|
<Setter Property="Template">
|
<Setter.Value>
|
<ControlTemplate TargetType="{x:Type ctrl:HxPasswordBox}">
|
<Border Grid.Column="1" Background="Transparent" BorderBrush="{TemplateBinding BorderBrush}"
|
BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"
|
>
|
<Grid>
|
<Grid.ColumnDefinitions>
|
<ColumnDefinition/>
|
<ColumnDefinition Width="Auto"/>
|
</Grid.ColumnDefinitions>
|
<TextBox x:Name="PART_PasswordText" BorderBrush="Transparent" BorderThickness="0" HorizontalAlignment="Stretch"
|
Foreground="{TemplateBinding Foreground}" Background="Transparent" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Visibility="Hidden"
|
Text="{TemplateBinding Password}" Style="{DynamicResource textBoxStyle}"/>
|
<PasswordBox x:Name="PART_Password" BorderBrush="Transparent" BorderThickness="0" HorizontalAlignment="Stretch"
|
Foreground="{TemplateBinding Foreground}" Background="Transparent" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/>
|
|
<!--<TextBlock x:Name="watermark" Text="{TemplateBinding WaterMark}" Background="Transparent" IsHitTestVisible="False"
|
Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
Foreground="{DynamicResource BrushWaterMark}" Visibility="Collapsed"/>-->
|
|
<ToggleButton x:Name="toggle" Grid.Column="1" Style="{StaticResource passwordToggleButtonStyle}"
|
IsChecked="{Binding ShowPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource ={RelativeSource TemplatedParent}}"/>
|
</Grid>
|
</Border>
|
|
<ControlTemplate.Triggers>
|
<Trigger Property="IsFocused" Value="True">
|
<Setter Property="BorderBrush" Value="{DynamicResource BrushPrimary}"/>
|
</Trigger>
|
<Trigger Property="IsMouseOver" Value="True">
|
<Setter Property="BorderBrush" Value="{DynamicResource BrushPrimary}"/>
|
</Trigger>
|
|
<DataTrigger Binding="{Binding ElementName=toggle,Path=IsChecked}" Value="True">
|
<Setter TargetName="PART_PasswordText" Property="Visibility" Value="Visible"/>
|
<Setter TargetName="PART_Password" Property="Visibility" Value="Hidden"/>
|
</DataTrigger>
|
<DataTrigger Binding="{Binding ElementName=toggle,Path=IsChecked}" Value="False">
|
<Setter TargetName="PART_PasswordText" Property="Visibility" Value="Hidden"/>
|
<Setter TargetName="PART_Password" Property="Visibility" Value="Visible"/>
|
</DataTrigger>
|
|
<!--<MultiTrigger>
|
<MultiTrigger.Conditions>
|
<Condition Property="IsEnabled" Value="True"/>
|
<Condition Property="HasText" Value="False"/>
|
<Condition Property="ShowWaterMark" Value="true"/>
|
</MultiTrigger.Conditions>
|
<MultiTrigger.Setters>
|
<Setter TargetName="watermark" Property="Visibility" Value="Visible"/>
|
</MultiTrigger.Setters>
|
</MultiTrigger>-->
|
</ControlTemplate.Triggers>
|
</ControlTemplate>
|
</Setter.Value>
|
</Setter>
|
</Style>
|
</ResourceDictionary>
|