TextBox.xaml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  4. <!-- TextBox Style -->
  5. <SolidColorBrush x:Key="TextBox_BD" Color="#FF1B1B1B"/>
  6. <SolidColorBrush x:Key="TextBox_BG" Color="White"/>
  7. <SolidColorBrush x:Key="TextBox_InnerBD" Color="#FFD6D6D6"/>
  8. <SolidColorBrush x:Key="TextBox_InnerLeft" Color="#FF898989"/>
  9. <SolidColorBrush x:Key="TextBox_InnerTop" Color="#FF565656"/>
  10. <SolidColorBrush x:Key="TextBox_InnerRight" Color="#FFD8D8D8"/>
  11. <SolidColorBrush x:Key="TextBox_InnerBottom" Color="#FFE0E0E0"/>
  12. <SolidColorBrush x:Key="TextBox_InnerBD_Unable" Color="#FFBEBDBD"/>
  13. <SolidColorBrush x:Key="TextBox_InnerLeft_Unable" Color="#FFABABAB"/>
  14. <SolidColorBrush x:Key="TextBox_InnerTop_Unable" Color="#FFB4B4B4"/>
  15. <SolidColorBrush x:Key="TextBox_InnerRight_Unable" Color="#FFE7E7E7"/>
  16. <SolidColorBrush x:Key="TextBox_InnerBottom_Unable" Color="#FFE7E7E7"/>
  17. <Style TargetType="{x:Type TextBox}">
  18. <Setter Property="SnapsToDevicePixels" Value="True"/>
  19. <Setter Property="FontFamily" Value="Arial" />
  20. <Setter Property="FontSize" Value="12" />
  21. <Setter Property="BorderThickness" Value="1,1,0,0"/>
  22. <Setter Property="MinHeight" Value="20" />
  23. <Setter Property="Background" Value="{DynamicResource TextBox_BG}" />
  24. <Setter Property="Foreground" Value="Black" />
  25. <Setter Property="BorderBrush" Value="{DynamicResource TextBox_BD}"/>
  26. <Setter Property="Padding" Value="5,1"/>
  27. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  28. <Setter Property="VerticalContentAlignment" Value="Center"/>
  29. <Setter Property="AllowDrop" Value="true"/>
  30. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  31. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  32. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  33. <Setter Property="Template">
  34. <Setter.Value>
  35. <ControlTemplate TargetType="{x:Type TextBox}">
  36. <Grid>
  37. <Border x:Name="TextBox_Outer" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  38. BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
  39. <Border x:Name="TextBox_Inner" BorderBrush="{DynamicResource TextBox_InnerBD}" BorderThickness="0,0,1,1" Padding="{TemplateBinding Padding}"/>
  40. </Border>
  41. <Rectangle x:Name="Lfet_Boder" Fill="{DynamicResource TextBox_InnerLeft}" HorizontalAlignment="Left" Width="1" Margin="1"/>
  42. <Rectangle x:Name="Top_Boder" Fill="{DynamicResource TextBox_InnerTop}" VerticalAlignment="Top" Height="1" Margin="1"/>
  43. <Rectangle x:Name="Right_Boder" Fill="{DynamicResource TextBox_InnerRight}" HorizontalAlignment="Right" Width="1" Margin="1,2,1,1"/>
  44. <Rectangle x:Name="Bottom_Boder" Fill="{DynamicResource TextBox_InnerBottom}" VerticalAlignment="Bottom" Height="1" Margin="1,1,2,1"/>
  45. <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
  46. </Grid>
  47. <ControlTemplate.Triggers>
  48. <Trigger Property="IsEnabled" Value="false">
  49. <Setter Property="BorderBrush" TargetName="TextBox_Outer" Value="{DynamicResource TextBox_BD_Unable}"/>
  50. <Setter Property="Background" TargetName="TextBox_Outer" Value="{DynamicResource TextBox_BG_Unable}"/>
  51. <Setter Property="BorderBrush" TargetName="TextBox_Inner" Value="{DynamicResource TextBox_InnerBD_Unable}"/>
  52. <Setter Property="Fill" TargetName="Lfet_Boder" Value="{DynamicResource TextBox_InnerLeft_Unable}"/>
  53. <Setter Property="Fill" TargetName="Top_Boder" Value="{DynamicResource TextBox_InnerTop_Unable}"/>
  54. <Setter Property="Fill" TargetName="Right_Boder" Value="{DynamicResource TextBox_InnerRight_Unable}"/>
  55. <Setter Property="Fill" TargetName="Bottom_Boder" Value="{DynamicResource TextBox_InnerBottom_Unable}"/>
  56. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  57. </Trigger>
  58. </ControlTemplate.Triggers>
  59. </ControlTemplate>
  60. </Setter.Value>
  61. </Setter>
  62. </Style>
  63. <Style TargetType="{x:Type PasswordBox}">
  64. <Setter Property="Background" Value="{DynamicResource TextBox_BG}" />
  65. <Setter Property="Foreground" Value="Black" />
  66. <Setter Property="BorderBrush" Value="{DynamicResource TextBox_BD}"/>
  67. <Setter Property="FontFamily" Value="Times New Roman"/>
  68. <Setter Property="PasswordChar" Value="●"/>
  69. <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
  70. <Setter Property="BorderThickness" Value="1"/>
  71. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  72. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  73. <Setter Property="AllowDrop" Value="true"/>
  74. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  75. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  76. <Setter Property="Template">
  77. <Setter.Value>
  78. <ControlTemplate TargetType="{x:Type PasswordBox}">
  79. <Grid>
  80. <Border x:Name="TextBox_Outer" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  81. BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
  82. <Border x:Name="TextBox_Inner" BorderBrush="{DynamicResource TextBox_InnerBD}" BorderThickness="0,0,1,1" Padding="{TemplateBinding Padding}"/>
  83. </Border>
  84. <Rectangle x:Name="Lfet_Boder" Fill="{DynamicResource TextBox_InnerLeft}" HorizontalAlignment="Left" Width="1" Margin="1"/>
  85. <Rectangle x:Name="Top_Boder" Fill="{DynamicResource TextBox_InnerTop}" VerticalAlignment="Top" Height="1" Margin="1"/>
  86. <Rectangle x:Name="Right_Boder" Fill="{DynamicResource TextBox_InnerRight}" HorizontalAlignment="Right" Width="1" Margin="1,2,1,1"/>
  87. <Rectangle x:Name="Bottom_Boder" Fill="{DynamicResource TextBox_InnerBottom}" VerticalAlignment="Bottom" Height="1" Margin="1,1,2,1"/>
  88. <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
  89. </Grid>
  90. <ControlTemplate.Triggers>
  91. <Trigger Property="IsEnabled" Value="false">
  92. <Setter Property="BorderBrush" TargetName="TextBox_Outer" Value="{DynamicResource TextBox_BD_Unable}"/>
  93. <Setter Property="Background" TargetName="TextBox_Outer" Value="{DynamicResource TextBox_BG_Unable}"/>
  94. <Setter Property="BorderBrush" TargetName="TextBox_Inner" Value="{DynamicResource TextBox_InnerBD_Unable}"/>
  95. <Setter Property="Fill" TargetName="Lfet_Boder" Value="{DynamicResource TextBox_InnerLeft_Unable}"/>
  96. <Setter Property="Fill" TargetName="Top_Boder" Value="{DynamicResource TextBox_InnerTop_Unable}"/>
  97. <Setter Property="Fill" TargetName="Right_Boder" Value="{DynamicResource TextBox_InnerRight_Unable}"/>
  98. <Setter Property="Fill" TargetName="Bottom_Boder" Value="{DynamicResource TextBox_InnerBottom_Unable}"/>
  99. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  100. </Trigger>
  101. </ControlTemplate.Triggers>
  102. </ControlTemplate>
  103. </Setter.Value>
  104. </Setter>
  105. </Style>
  106. <ControlTemplate x:Key="ValidationTemplate">
  107. <DockPanel>
  108. <Border BorderBrush="Red" BorderThickness="1">
  109. <AdornedElementPlaceholder/>
  110. </Border>
  111. <TextBlock Foreground="Red" FontSize="20">*</TextBlock>
  112. </DockPanel>
  113. </ControlTemplate>
  114. <!-- TextBox_Top Style -->
  115. <SolidColorBrush x:Key="TextBox_Top_BG" Color="#FFbee9e8"/>
  116. <SolidColorBrush x:Key="TextBox_Top_Shadow" Color="#FF1B1B1B"/>
  117. <SolidColorBrush x:Key="TextBox_Top_Highlight_Right" Color="#B2AFC2D3"/>
  118. <SolidColorBrush x:Key="TextBox_Top_Highlight_Bottom" Color="#FFD2D2D2"/>
  119. <Style x:Key="TextBox_Top" TargetType="{x:Type TextBox}">
  120. <Setter Property="SnapsToDevicePixels" Value="True"/>
  121. <Setter Property="FontFamily" Value="Arial" />
  122. <Setter Property="FontSize" Value="14" />
  123. <Setter Property="Margin" Value="0,2,2,2"/>
  124. <Setter Property="BorderThickness" Value="0,1,1,1"/>
  125. <Setter Property="Background" Value="{DynamicResource TextBox_Top_BG}" />
  126. <Setter Property="Foreground" Value="{DynamicResource Foreground_Black}" />
  127. <Setter Property="BorderBrush" Value="{DynamicResource TextBox_Top_Highlight_Right}"/>
  128. <Setter Property="Border.CornerRadius" Value="0,6,6,0"/>
  129. <Setter Property="HorizontalAlignment" Value="Stretch"/>
  130. <Setter Property="VerticalAlignment" Value="Stretch"/>
  131. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  132. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  133. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  134. <Setter Property="Template">
  135. <Setter.Value>
  136. <ControlTemplate TargetType="{x:Type TextBox}">
  137. <Grid>
  138. <Border x:Name="TextBox_Bg" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" CornerRadius="{TemplateBinding Border.CornerRadius}"
  139. BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
  140. <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="5,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
  141. </Border>
  142. </Grid>
  143. <ControlTemplate.Triggers>
  144. <Trigger Property="IsEnabled" Value="false">
  145. <Setter Property="Background" TargetName="TextBox_Bg" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
  146. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  147. </Trigger>
  148. </ControlTemplate.Triggers>
  149. </ControlTemplate>
  150. </Setter.Value>
  151. </Setter>
  152. </Style>
  153. <Style x:Key="TextBox_RightTop" TargetType="{x:Type TextBox}" BasedOn="{StaticResource TextBox_Top}"/>
  154. <!-- Login TextBox -->
  155. <SolidColorBrush x:Key="TextBox_Login_BG" Color="#FF1E4F8A"/>
  156. <SolidColorBrush x:Key="TextBox_Login_BD" Color="#FF0A2B58"/>
  157. <SolidColorBrush x:Key="TextBox_BG_Unable" Color="Gainsboro"/>
  158. <SolidColorBrush x:Key="TextBox_BD_Unable" Color="#FF747474"/>
  159. <Style x:Key="Login_TextBox" TargetType="{x:Type TextBox}">
  160. <Setter Property="SnapsToDevicePixels" Value="True"/>
  161. <Setter Property="FontFamily" Value="Arial" />
  162. <Setter Property="FontSize" Value="14" />
  163. <Setter Property="BorderThickness" Value="2"/>
  164. <Setter Property="MinHeight" Value="20" />
  165. <Setter Property="Background" Value="{StaticResource TextBox_Login_BG}"/>
  166. <Setter Property="Foreground" Value="{DynamicResource FG_White}" />
  167. <Setter Property="BorderBrush" Value="{StaticResource TextBox_Login_BD}"/>
  168. <Setter Property="Padding" Value="5,1"/>
  169. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  170. <Setter Property="VerticalContentAlignment" Value="Center"/>
  171. <Setter Property="AllowDrop" Value="true"/>
  172. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  173. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  174. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  175. <Setter Property="Template">
  176. <Setter.Value>
  177. <ControlTemplate TargetType="{x:Type TextBox}">
  178. <Border x:Name="BG" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
  179. <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
  180. </Border>
  181. <ControlTemplate.Triggers>
  182. <Trigger Property="IsEnabled" Value="false">
  183. <Setter Property="BorderBrush" TargetName="BG" Value="{StaticResource TextBox_BD_Unable}"/>
  184. <Setter Property="Background" TargetName="BG" Value="{StaticResource TextBox_BG_Unable}"/>
  185. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  186. </Trigger>
  187. </ControlTemplate.Triggers>
  188. </ControlTemplate>
  189. </Setter.Value>
  190. </Setter>
  191. </Style>
  192. <Style x:Key="Login_PasswordBox" TargetType="{x:Type PasswordBox}">
  193. <Setter Property="Background" Value="{StaticResource TextBox_Login_BG}"/>
  194. <Setter Property="Foreground" Value="{DynamicResource FG_White}" />
  195. <Setter Property="BorderBrush" Value="{StaticResource TextBox_Login_BD}"/>
  196. <Setter Property="SnapsToDevicePixels" Value="True"/>
  197. <Setter Property="FontFamily" Value="Arial" />
  198. <Setter Property="PasswordChar" Value="●"/>
  199. <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
  200. <Setter Property="BorderThickness" Value="2"/>
  201. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  202. <Setter Property="VerticalContentAlignment" Value="Center"/>
  203. <Setter Property="Padding" Value="5,1"/>
  204. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  205. <Setter Property="AllowDrop" Value="true"/>
  206. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  207. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  208. <Setter Property="Template">
  209. <Setter.Value>
  210. <ControlTemplate TargetType="{x:Type PasswordBox}">
  211. <Border x:Name="BG" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
  212. <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
  213. </Border>
  214. <ControlTemplate.Triggers>
  215. <Trigger Property="IsEnabled" Value="false">
  216. <Setter Property="BorderBrush" TargetName="BG" Value="{StaticResource TextBox_BD_Unable}"/>
  217. <Setter Property="Background" TargetName="BG" Value="{StaticResource TextBox_BG_Unable}"/>
  218. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  219. </Trigger>
  220. </ControlTemplate.Triggers>
  221. </ControlTemplate>
  222. </Setter.Value>
  223. </Setter>
  224. </Style>
  225. </ResourceDictionary>