PasswordBoxControl.xaml 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <UserControl x:Class="ComPDFKit.Controls.Common.PasswordBoxControl"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:helper="clr-namespace:PasswordBoxPlus.Helper"
  7. mc:Ignorable="d"
  8. xmlns:common="clr-namespace:ComPDFKit.Controls.Common"
  9. d:DesignHeight="36" d:DesignWidth="200">
  10. <UserControl.Resources>
  11. <ResourceDictionary>
  12. <common:AntiStringToVisibilityConverter x:Key="AntiStringToVisibilityConverter"></common:AntiStringToVisibilityConverter>
  13. <common:StringToVisibilityConverter x:Key="StringToVisibilityConverter"></common:StringToVisibilityConverter>
  14. <common:BoolToVisibleConverter x:Key="BoolToVisibilityConverter"></common:BoolToVisibleConverter>
  15. <common:AntiBoolToVisibilityConverter x:Key="AntiBoolToVisibilityConverter"></common:AntiBoolToVisibilityConverter>
  16. <ResourceDictionary.MergedDictionaries>
  17. <ResourceDictionary Source="../../Asset/Styles/RoundCornerPasswordBoxStyle.xaml"></ResourceDictionary>
  18. <ResourceDictionary Source="../../Asset/Styles/RoundCornerTextBoxStyle.xaml"></ResourceDictionary>
  19. <ResourceDictionary Source="../../Asset/Styles/EyeCheckBoxStyle.xaml"></ResourceDictionary>
  20. </ResourceDictionary.MergedDictionaries>
  21. </ResourceDictionary>
  22. </UserControl.Resources>
  23. <Grid x:Name="Grid">
  24. <Grid.ColumnDefinitions>
  25. <ColumnDefinition></ColumnDefinition>
  26. <ColumnDefinition Width="24"></ColumnDefinition>
  27. </Grid.ColumnDefinitions>
  28. <PasswordBox x:Name="PasswordBox" Grid.ColumnSpan="2" Style="{StaticResource RoundCornerPasswordBoxStyle}"
  29. helper:PasswordHelper.Attach="true" helper:PasswordHelper.Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
  30. Visibility="{Binding ElementName=DisplayPasswordChk, Path=IsChecked, Converter={StaticResource AntiBoolToVisibilityConverter}}">
  31. </PasswordBox>
  32. <TextBox Grid.ColumnSpan="2" x:Name="TextBox" Style="{StaticResource PasswordTextBoxStyle}"
  33. Visibility="{Binding ElementName=DisplayPasswordChk, Path=IsChecked, Converter={StaticResource BoolToVisibilityConverter}}"
  34. Text="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextChanged="TextBox_TextChanged">
  35. </TextBox>
  36. <TextBlock x:Name="TextBlock" IsHitTestVisible="False" Text="{Binding Watermark, RelativeSource={RelativeSource AncestorType=UserControl}}"
  37. VerticalAlignment="Center" FontSize="13" Margin="15,0,0,0" Foreground="#BBB"
  38. Visibility="{Binding Password, Converter={StaticResource StringToVisibilityConverter}}">
  39. </TextBlock>
  40. <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>
  41. </Grid>
  42. </UserControl>