TextBoxStyle.xaml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
  4. <!--通用文本样式-->
  5. <Style TargetType="TextBox">
  6. <Setter Property="Margin" Value="0,10" />
  7. <Setter Property="Height" Value="35" />
  8. <!--<Setter Property="Width" Value="190"></Setter>-->
  9. <Setter Property="FontSize" Value="18" />
  10. <Setter Property="Background" Value="#FFDCF7F6"></Setter>
  11. <Style.Triggers>
  12. <Trigger Property="IsMouseOver" Value="True">
  13. <Setter Property="Foreground" Value="Green" />
  14. <Setter Property="BorderBrush" Value="Green" />
  15. <Setter Property="BorderThickness" Value="2" />
  16. </Trigger>
  17. <Trigger Property="Validation.HasError" Value="true">
  18. <Setter Property="ToolTip"
  19. Value="{Binding RelativeSource={x:Static RelativeSource.Self},
  20. Path=(Validation.Errors)[0].ErrorContent}"/>
  21. </Trigger>
  22. </Style.Triggers>
  23. </Style>
  24. <Style TargetType="TextBox" x:Key="SmallTextBox" BasedOn="{StaticResource {x:Type TextBox}}">
  25. <Setter Property="Height" Value="25"/>
  26. <Setter Property="FontSize" Value="12" />
  27. </Style>
  28. <!--Notch文本框样式-->
  29. <Style TargetType="{x:Type TextBox}" x:Key="NotchTextBox">
  30. <Setter Property="VerticalContentAlignment" Value="Center"/>
  31. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  32. <Setter Property="Width" Value="50"/>
  33. <Setter Property="Height" Value="50"/>
  34. <Setter Property="Template">
  35. <Setter.Value>
  36. <ControlTemplate TargetType="{x:Type TextBox}">
  37. <Grid x:Name="grid">
  38. <Rectangle x:Name="rectangle1" RadiusX="25" RadiusY="25" Fill="{TemplateBinding Background}" StrokeThickness="1" Stroke="Black"/>
  39. <ScrollViewer x:Name="PART_ContentHost"
  40. HorizontalScrollBarVisibility="Hidden"
  41. VerticalScrollBarVisibility="Hidden"
  42. Padding="{TemplateBinding Padding}"
  43. Focusable="false">
  44. </ScrollViewer>
  45. </Grid>
  46. </ControlTemplate>
  47. </Setter.Value>
  48. </Setter>
  49. </Style>
  50. <!--反应腔盖-->
  51. <Style TargetType="TextBox" x:Key="ReactorMiniTextBox">
  52. <Setter Property="Width" Value="30" />
  53. <Setter Property="Cursor" Value="Hand" />
  54. </Style>
  55. <!-- TextBox_Top Style -->
  56. <SolidColorBrush x:Key="TextBox_Top_BG" Color="White"/>
  57. <SolidColorBrush x:Key="TextBox_Top_Shadow" Color="#FF1B1B1B"/>
  58. <SolidColorBrush x:Key="TextBox_Top_Highlight_Right" Color="#FFB4B4B4"/>
  59. <SolidColorBrush x:Key="TextBox_Top_Highlight_Bottom" Color="#FFD2D2D2"/>
  60. <Style x:Key="TextBox_Top" TargetType="{x:Type TextBox}">
  61. <Setter Property="SnapsToDevicePixels" Value="True"/>
  62. <Setter Property="FontFamily" Value="Arial" />
  63. <Setter Property="FontSize" Value="14" />
  64. <Setter Property="BorderThickness" Value="2,2,0,0"/>
  65. <Setter Property="MinHeight" Value="20" />
  66. <Setter Property="Background" Value="{DynamicResource TextBox_Top_BG}" />
  67. <Setter Property="Foreground" Value="{DynamicResource Foreground_Black}" />
  68. <Setter Property="BorderBrush" Value="{DynamicResource TextBox_Top_Shadow}"/>
  69. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  70. <Setter Property="VerticalContentAlignment" Value="Center"/>
  71. <Setter Property="AllowDrop" Value="true"/>
  72. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  73. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  74. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  75. <Setter Property="Template">
  76. <Setter.Value>
  77. <ControlTemplate TargetType="{x:Type TextBox}">
  78. <Grid>
  79. <Border x:Name="TextBox_Bg" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  80. BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
  81. <Grid>
  82. <Rectangle Fill="{DynamicResource TextBox_Top_Highlight_Right}" HorizontalAlignment="Right" Width="2"/>
  83. <Rectangle Fill="{DynamicResource TextBox_Top_Highlight_Bottom}" VerticalAlignment="Bottom" Height="2"/>
  84. <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="5,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
  85. </Grid>
  86. </Border>
  87. </Grid>
  88. <ControlTemplate.Triggers>
  89. <Trigger Property="IsEnabled" Value="false">
  90. <Setter Property="Background" TargetName="TextBox_Bg" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
  91. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  92. </Trigger>
  93. </ControlTemplate.Triggers>
  94. </ControlTemplate>
  95. </Setter.Value>
  96. </Setter>
  97. </Style>
  98. <!-- Login TextBox Style -->
  99. <LinearGradientBrush x:Key="LoginTextBox_BG" EndPoint="0.5,1" StartPoint="0.5,0">
  100. <GradientStop Color="#FFC8C8C8" Offset="0"/>
  101. <GradientStop Color="#FFE9E9E9" Offset="1"/>
  102. </LinearGradientBrush>
  103. <SolidColorBrush x:Key="LoginTextBox_ShadowBD" Color="#FF787878"/>
  104. <SolidColorBrush x:Key="LoginTextBox_HighlightBD" Color="White"/>
  105. <Style TargetType="TextBox" x:Key="LoginTextBox">
  106. <Setter Property="SnapsToDevicePixels" Value="True"/>
  107. <Setter Property="FontFamily" Value="Arial,Simsun" />
  108. <Setter Property="FontSize" Value="16" />
  109. <Setter Property="BorderThickness" Value="2,2,0,0"/>
  110. <Setter Property="MinHeight" Value="20" />
  111. <Setter Property="Background" Value="{DynamicResource LoginTextBox_BG}" />
  112. <Setter Property="Foreground" Value="Black" />
  113. <Setter Property="BorderBrush" Value="{DynamicResource LoginTextBox_ShadowBD}"/>
  114. <Setter Property="Padding" Value="5,1"/>
  115. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  116. <Setter Property="VerticalContentAlignment" Value="Center"/>
  117. <Setter Property="AllowDrop" Value="true"/>
  118. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  119. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  120. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  121. <Setter Property="Template">
  122. <Setter.Value>
  123. <ControlTemplate TargetType="TextBoxBase">
  124. <Grid>
  125. <Border x:Name="Focus_Border" BorderBrush="#FFFFEA00" BorderThickness="2" Opacity="0"/>
  126. <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Margin="2">
  127. <Border x:Name="Inner_BG" BorderBrush="{DynamicResource LoginTextBox_HighlightBD}" BorderThickness="0,0,2,2">
  128. <ScrollViewer Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
  129. </Border>
  130. </Border>
  131. </Grid>
  132. <ControlTemplate.Triggers>
  133. <Trigger Property="UIElement.IsEnabled" Value="False">
  134. <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
  135. <Setter Property="Control.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
  136. </Trigger>
  137. <Trigger Property="IsFocused" Value="True">
  138. <Setter Property="Opacity" TargetName="Focus_Border" Value="1"/>
  139. </Trigger>
  140. </ControlTemplate.Triggers>
  141. </ControlTemplate>
  142. </Setter.Value>
  143. </Setter>
  144. </Style>
  145. </ResourceDictionary>