PasswordBoxStyle.xaml 4.75 KB
<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
	<ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="TextBoxStyle.xaml"/>
	</ResourceDictionary.MergedDictionaries>
	<!-- Resource dictionary entries should be defined here. -->
	<Style x:Key="PasswordBoxStyle" TargetType="{x:Type PasswordBox}">
		<Setter Property="PasswordChar" Value="●"/>
        <Setter Property="Foreground" Value="{DynamicResource ForegroundNormalColorBrush}"/>
        <Setter Property="Background" Value="{DynamicResource CommonBackgroundBrush}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource ButtonNormalBorder}"/>
        <Setter Property="BorderThickness" Value="1"/>
		<Setter Property="Padding" Value="1"/>
		<Setter Property="AllowDrop" Value="true"/>
		<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
		<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
		<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type PasswordBox}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.4" To="MouseOver"/>
                                    <VisualTransition From="MouseOver" GeneratedDuration="0:0:0.4">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0:0:0.4" From="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="MouseOverBorder"/>
                                        </Storyboard>
                                    </VisualTransition>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="DisabledBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="ReadOnly"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="MouseOverBorder">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="1">
                                                <EasingDoubleKeyFrame.EasingFunction>
                                                    <QuinticEase EasingMode="EaseOut"/>
                                                </EasingDoubleKeyFrame.EasingFunction>
                                            </EasingDoubleKeyFrame>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ValidationStates">
                                <VisualState x:Name="Valid"/>
                                <VisualState x:Name="InvalidFocused"/>
                                <VisualState x:Name="InvalidUnfocused"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="OuterBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" />
                        <Border x:Name="MouseOverBorder" BorderBrush="{DynamicResource ButtonCheckingColorBrush2}" BorderThickness="1" Margin="1" Opacity="0" />
                        <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}"/>
                        <Border x:Name="DisabledBorder" BorderThickness="1" Background="{DynamicResource GrayLightBrush}" Opacity="0.5" Visibility="Collapsed" />
                    </Grid>
                </ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>