Permalink
Browse files

PasswordBox: better DefaultCapsLockIcon, minor style fixes

  • Loading branch information...
1 parent 9f974d0 commit 709abc49abb575017a8bb660bc129656172824b5 @punker76 punker76 committed Feb 19, 2015
Showing with 29 additions and 15 deletions.
  1. +26 −14 MahApps.Metro/Styles/Controls.PasswordBox.xaml
  2. +3 −1 samples/MetroDemo/ExampleViews/TextExamples.xaml
@@ -10,9 +10,30 @@
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<Converters:ThicknessToDoubleConverter x:Key="ThicknessToDoubleConverter" />
+ <Grid x:Key="DefaultCapsLockIcon"
+ x:Shared="False"
+ Background="{DynamicResource BlackBrush}"
+ Opacity="0.8"
+ Width="16"
+ Height="16">
+ <Grid.OpacityMask>
+ <VisualBrush>
+ <VisualBrush.Visual>
+ <Canvas Width="24"
+ Height="24">
+ <Path Data="M13,14H11V10H13M13,18H11V16H13M1,21H23L12,2L1,21Z"
+ Fill="Black" />
+ </Canvas>
+ </VisualBrush.Visual>
+ </VisualBrush>
+ </Grid.OpacityMask>
+ </Grid>
+
<!--PasswordBox Style-->
<Style TargetType="{x:Type PasswordBox}"
x:Key="MetroPasswordBox">
+ <Setter Property="Controls:PasswordBoxHelper.CapsLockIcon"
+ Value="{StaticResource DefaultCapsLockIcon}" />
<Setter Property="ContextMenu"
Value="{DynamicResource TextBoxMetroContextMenu}" />
<Setter Property="Controls:TextBoxHelper.IsMonitoring"
@@ -87,7 +108,6 @@
<Grid Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
- <ColumnDefinition Width="{Binding ElementName=ButtonRow, Path=ActualHeight, Mode=OneWay}" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition x:Name="ButtonColumn"
Width="Auto" />
@@ -151,18 +171,19 @@
FontFamily="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextBoxHelper.ButtonFontFamily), Mode=OneWay}"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextBoxHelper.ButtonContent), Mode=OneWay}"
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextBoxHelper.ClearTextButton), Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"
+ Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ButtonWidth), Mode=OneWay}"
IsTabStop="False" />
<ContentPresenter x:Name="PART_CapsLockIndicator"
Grid.Row="0"
Grid.Column="1"
Grid.RowSpan="2"
+ Margin="1"
TextBlock.Foreground="{DynamicResource ControlsValidationBrush}"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:PasswordBoxHelper.CapsLockIcon), Mode=TwoWay}"
VerticalAlignment="Center"
HorizontalAlignment="Right"
ToolTip="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:PasswordBoxHelper.CapsLockWarningToolTip), Mode=OneWay}"
- Visibility="Collapsed"
- Width="16" />
+ Visibility="Collapsed" />
</Grid>
<Rectangle x:Name="DisabledVisualElement"
Stroke="{DynamicResource ControlsDisabledBrush}"
@@ -210,15 +231,6 @@
</DataTrigger.ExitActions>
</DataTrigger>
- <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Controls:TextBoxHelper.ClearTextButton)}"
- Value="False">
- <Setter TargetName="PART_ContentHost"
- Property="Grid.ColumnSpan"
- Value="2" />
- <Setter TargetName="Message"
- Property="Grid.ColumnSpan"
- Value="2" />
- </DataTrigger>
<Trigger Property="IsMouseOver"
Value="True">
<Setter TargetName="FocusRectangle"
@@ -419,13 +431,13 @@
Grid.Row="0"
Grid.Column="1"
Grid.RowSpan="2"
+ Margin="1"
TextBlock.Foreground="{DynamicResource ControlsValidationBrush}"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:PasswordBoxHelper.CapsLockIcon), Mode=TwoWay}"
VerticalAlignment="Center"
HorizontalAlignment="Right"
ToolTip="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:PasswordBoxHelper.CapsLockWarningToolTip), Mode=OneWay}"
- Visibility="Collapsed"
- Width="16" />
+ Visibility="Collapsed" />
</Grid>
<Rectangle x:Name="DisabledVisualElement"
Stroke="{DynamicResource ControlsDisabledBrush}"
@@ -172,10 +172,12 @@
<Label Content="PasswordBox"
Style="{DynamicResource DescriptionHeaderStyle}" />
<PasswordBox Margin="0, 10, 0, 0"
+ Controls:TextBoxHelper.Watermark="Password"
Password="Password" />
<PasswordBox Margin="0, 10, 0, 0"
+ Controls:TextBoxHelper.Watermark="Password"
+ Controls:TextBoxHelper.UseFloatingWatermark="True"
Controls:TextBoxHelper.ClearTextButton="True"
- Controls:PasswordBoxHelper.CapsLockIcon="!"
Controls:TextBoxHelper.ButtonCommand="{Binding TextBoxButtonCmd, Mode=OneWay}"
Password="Password" />
<PasswordBox Margin="0, 10, 0, 0"

0 comments on commit 709abc4

Please sign in to comment.