<UserControl x:Class="ComPDFKit.Controls.Common.PasswordBoxControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:helper="clr-namespace:PasswordBoxPlus.Helper"
             mc:Ignorable="d" 
            xmlns:common="clr-namespace:ComPDFKit.Controls.Common"
            d:DesignHeight="36" d:DesignWidth="200">
    <UserControl.Resources>
        <ResourceDictionary>
            <common:AntiStringToVisibilityConverter x:Key="AntiStringToVisibilityConverter"></common:AntiStringToVisibilityConverter>
            <common:StringToVisibilityConverter x:Key="StringToVisibilityConverter"></common:StringToVisibilityConverter>
            <common:BoolToVisibleConverter x:Key="BoolToVisibilityConverter"></common:BoolToVisibleConverter>
            <common:AntiBoolToVisibilityConverter x:Key="AntiBoolToVisibilityConverter"></common:AntiBoolToVisibilityConverter>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Asset/Styles/RoundCornerPasswordBoxStyle.xaml"></ResourceDictionary>
                <ResourceDictionary Source="../../Asset/Styles/RoundCornerTextBoxStyle.xaml"></ResourceDictionary>
                <ResourceDictionary Source="../../Asset/Styles/EyeCheckBoxStyle.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid x:Name="Grid">
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition Width="24"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <PasswordBox x:Name="PasswordBox" Grid.ColumnSpan="2" Style="{StaticResource RoundCornerPasswordBoxStyle}" 
                     helper:PasswordHelper.Attach="true" helper:PasswordHelper.Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                     Visibility="{Binding ElementName=DisplayPasswordChk, Path=IsChecked, Converter={StaticResource AntiBoolToVisibilityConverter}}">
        </PasswordBox>

        <TextBox Grid.ColumnSpan="2" x:Name="TextBox" Style="{StaticResource PasswordTextBoxStyle}" 
                 Visibility="{Binding ElementName=DisplayPasswordChk, Path=IsChecked, Converter={StaticResource BoolToVisibilityConverter}}" 
                 Text="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextChanged="TextBox_TextChanged">
        </TextBox>

        <TextBlock x:Name="TextBlock" IsHitTestVisible="False" Text="{Binding Watermark, RelativeSource={RelativeSource AncestorType=UserControl}}"
                   VerticalAlignment="Center" FontSize="13" Margin="15,0,0,0" Foreground="#BBB" 
                   Visibility="{Binding Password, Converter={StaticResource StringToVisibilityConverter}}">
        </TextBlock>
        <CheckBox x:Name="DisplayPasswordChk" Style="{StaticResource EyeCheckBoxStyle}" Visibility="{Binding Password, Converter={StaticResource AntiStringToVisibilityConverter}}" Height="16" Grid.Column="1" HorizontalAlignment="Left" Panel.ZIndex="1" IsChecked="False"></CheckBox>
    </Grid>
</UserControl>
