TextBoxStyle.xaml 3.78 KB
<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	<ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="..\Colors\Colors.xaml"/>
	</ResourceDictionary.MergedDictionaries>

	<Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}">
        <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="FontSize" Value="15"/>
        <Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type TextBox}">
					<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.Triggers>
						<Trigger Property="IsReadOnly" Value="True">
							<Setter Property="Foreground" Value="{DynamicResource GrayDarkBrush}"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="SelectionBrush" Value="{DynamicResource ButtonNormalBackground}"/>
	</Style>
</ResourceDictionary>