StylePasswordBox.xaml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  3. <Style TargetType="PasswordBox">
  4. <Setter Property="FontSize" Value="14"/>
  5. <Setter Property="Height" Value="40"/>
  6. <Setter Property="Width" Value="250"/>
  7. <Setter Property="Background" Value="white"/>
  8. <Setter Property="Foreground" Value="#59A862"/>
  9. <Setter Property="FontWeight" Value="UltraLight"/>
  10. <Setter Property="Padding" Value="0 5 5 4"/>
  11. <Setter Property="Margin" Value="10 5"/>
  12. <Setter Property="Cursor" Value="IBeam"/>
  13. <Setter Property="VerticalContentAlignment" Value="Center"/>
  14. <Setter Property="HorizontalAlignment" Value="Center"/>
  15. <Setter Property="VerticalAlignment" Value="Center"/>
  16. <Setter Property="Grid.Column" Value="1"/>
  17. <Setter Property="Template">
  18. <Setter.Value>
  19. <ControlTemplate TargetType="{x:Type PasswordBox}">
  20. <Border x:Name="TxtBorder"
  21. Background="{TemplateBinding Background}"
  22. BorderThickness="{TemplateBinding BorderThickness}"
  23. BorderBrush="{TemplateBinding BorderBrush}"
  24. CornerRadius="5"
  25. SnapsToDevicePixels="True">
  26. <Grid Margin="{TemplateBinding Padding}">
  27. <Grid.ColumnDefinitions>
  28. <ColumnDefinition Width="*"/>
  29. </Grid.ColumnDefinitions>
  30. <ScrollViewer x:Name="PART_ContentHost"
  31. Focusable="False"
  32. Grid.Column="1"
  33. Margin="5 0 0 0"
  34. HorizontalScrollBarVisibility="Hidden"
  35. VerticalScrollBarVisibility="Hidden"/>
  36. <Label x:Name="Watermark"
  37. FontFamily="Gabriela"
  38. FontSize="15"
  39. VerticalAlignment="Center"
  40. HorizontalAlignment="Left"
  41. Foreground="#59A862"
  42. Visibility="Collapsed"
  43. Padding="5 0 20 0"
  44. Content="{TemplateBinding Tag}"
  45. Grid.Column="1"/>
  46. </Grid>
  47. </Border>
  48. <ControlTemplate.Triggers>
  49. <Trigger Property="IsMouseOver" Value="True">
  50. <Setter Property="BorderBrush" Value="#498C51" TargetName="TxtBorder"/>
  51. <Setter Property="Control.Foreground" Value="#498C51"/>
  52. <Setter Property="Foreground" TargetName="Watermark" Value="#498C51"/>
  53. <Setter Property="Visibility" Value="Collapsed" TargetName="Watermark"/>
  54. </Trigger>
  55. <Trigger Property="IsKeyboardFocused" Value="True">
  56. <Setter Property="Control.Foreground" Value="#498C51"/>
  57. <Setter Property="BorderBrush" Value="#498C51" TargetName="TxtBorder"/>
  58. <Setter Property="Foreground" TargetName="Watermark" Value="#498C51"/>
  59. </Trigger>
  60. <Trigger Property="IsKeyboardFocused" Value="False">
  61. <Setter Property="Visibility" Value="Visible" TargetName="Watermark"/>
  62. </Trigger>
  63. </ControlTemplate.Triggers>
  64. </ControlTemplate>
  65. </Setter.Value>
  66. </Setter>
  67. </Style>
  68. </ResourceDictionary>