/V2.2/trunk/Quickstarts/Modularity/DirectoryLookupModularity/DirectoryLookupModularity/Styles/styles.xaml

# · XAML · 368 lines · 276 code · 47 blank · 45 comment · 0 complexity · 797410381d722dfeab71447a0b52cdd6 MD5 · raw file

  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/interactivedesigner/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
  2. <!-- SimpleStyles.XAML defines a set of control styles which are simplified starting points for creating your own controls -->
  3. <!-- Brushes : These are used to define the color for background, foreground, selection, enabled etc of all controls
  4. If you want to change the color of a control you can just chnage the brush; if you want to add a new shape or change arrangement then also edit the template -->
  5. <!-- NormalBrush is used as the Background for SimpleButton, SimpleRepeatButton -->
  6. <LinearGradientBrush x:Key="NormalBrush" EndPoint="0,1" StartPoint="0,0">
  7. <GradientStop Color="#EEE" Offset="0.0"/>
  8. <GradientStop Color="#CCC" Offset="1.0"/>
  9. </LinearGradientBrush>
  10. <LinearGradientBrush x:Key="NormalBorderBrush" EndPoint="0,1" StartPoint="0,0">
  11. <GradientStop Color="#CCC" Offset="0.0"/>
  12. <GradientStop Color="#444" Offset="1.0"/>
  13. </LinearGradientBrush>
  14. <!-- LightBrush is used for content areas such as Menu, Tab Control background -->
  15. <LinearGradientBrush x:Key="LightBrush" EndPoint="0,1" StartPoint="0,0">
  16. <GradientStop Color="#FFF" Offset="0.0"/>
  17. <GradientStop Color="#EEE" Offset="1.0"/>
  18. </LinearGradientBrush>
  19. <!-- MouseOverBrush is used for MouseOver in Button, Radio Button, CheckBox -->
  20. <LinearGradientBrush x:Key="MouseOverBrush" EndPoint="0,1" StartPoint="0,0">
  21. <GradientStop Color="#FFF" Offset="0.0"/>
  22. <GradientStop Color="#AAA" Offset="1.0"/>
  23. </LinearGradientBrush>
  24. <!-- PressedBrush is used for Pressed in Button, Radio Button, CheckBox -->
  25. <LinearGradientBrush x:Key="PressedBrush" EndPoint="0,1" StartPoint="0,0">
  26. <GradientStop Color="#BBB" Offset="0.0"/>
  27. <GradientStop Color="#EEE" Offset="0.1"/>
  28. <GradientStop Color="#EEE" Offset="0.9"/>
  29. <GradientStop Color="#FFF" Offset="1.0"/>
  30. </LinearGradientBrush>
  31. <LinearGradientBrush x:Key="PressedBorderBrush" EndPoint="0,1" StartPoint="0,0">
  32. <GradientStop Color="#444" Offset="0.0"/>
  33. <GradientStop Color="#888" Offset="1.0"/>
  34. </LinearGradientBrush>
  35. <!-- SelectedBackgroundBrush is used for the Selected item in ListBoxItem, ComboBoxItem-->
  36. <SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#DDD"/>
  37. <!-- Disabled Brushes are used for the Disabled look of each control -->
  38. <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888"/>
  39. <SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE"/>
  40. <SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA"/>
  41. <!-- Used for background of ScrollViewer, TreeView, ListBox, Expander, TextBox, Tab Control -->
  42. <SolidColorBrush x:Key="WindowBackgroundBrush" Color="#FFF"/>
  43. <!-- DefaultedBorderBrush is used to show KeyBoardFocus -->
  44. <LinearGradientBrush x:Key="DefaultedBorderBrush" EndPoint="0,1" StartPoint="0,0">
  45. <GradientStop Color="#777" Offset="0.0"/>
  46. <GradientStop Color="#000" Offset="1.0"/>
  47. </LinearGradientBrush>
  48. <SolidColorBrush x:Key="SolidBorderBrush" Color="#888"/>
  49. <SolidColorBrush x:Key="LightBorderBrush" Color="#AAA"/>
  50. <SolidColorBrush x:Key="LightColorBrush" Color="#DDD"/>
  51. <!-- Used for Checkmark, Radio button, TreeViewItem, Expander ToggleButton glyphs -->
  52. <SolidColorBrush x:Key="GlyphBrush" Color="#444"/>
  53. <!-- Style and Template pairs are used to define each control Part -->
  54. <!-- The Style provides default values on the control; the Template gives the elements for each control -->
  55. <!-- SimpleButtonFocusVisual is used to show keyboard focus around a SimpleButton control -->
  56. <Style x:Key="SimpleButtonFocusVisual">
  57. <Setter Property="Control.Template">
  58. <Setter.Value>
  59. <ControlTemplate>
  60. <Border>
  61. <Rectangle Margin="2" Stroke="#60000000" StrokeThickness="1" StrokeDashArray="1 2"/>
  62. </Border>
  63. </ControlTemplate>
  64. </Setter.Value>
  65. </Setter>
  66. </Style>
  67. <!-- Simple Button - This control sets brushes on each state. Note that these brushes must be listed above since they are static resources -->
  68. <Style x:Key="SimpleButton" TargetType="{x:Type Button}" BasedOn="{x:Null}">
  69. <Setter Property="FocusVisualStyle" Value="{DynamicResource SimpleButtonFocusVisual}"/>
  70. <Setter Property="Background" Value="{DynamicResource NormalBrush}"/>
  71. <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
  72. <Setter Property="Template">
  73. <Setter.Value>
  74. <ControlTemplate TargetType="{x:Type Button}">
  75. <!-- We use Grid as a root because it is easy to add more elements to customize the button -->
  76. <Grid x:Name="Grid">
  77. <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"/>
  78. <!-- Content Presenter is where the text content etc is placed by the control -->
  79. <!-- The bindings are useful so that the control can be parameterized without editing the template -->
  80. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
  81. </Grid>
  82. <!--Each state sets a brush on the Border in the template -->
  83. <ControlTemplate.Triggers>
  84. <Trigger Property="IsKeyboardFocused" Value="true">
  85. <Setter Property="BorderBrush" Value="{DynamicResource DefaultedBorderBrush}" TargetName="Border"/>
  86. </Trigger>
  87. <Trigger Property="IsMouseOver" Value="true">
  88. <Setter Property="Background" Value="{DynamicResource MouseOverBrush}" TargetName="Border"/>
  89. </Trigger>
  90. <Trigger Property="IsPressed" Value="true">
  91. <Setter Property="Background" Value="{DynamicResource PressedBrush}" TargetName="Border"/>
  92. <Setter Property="BorderBrush" Value="{DynamicResource PressedBorderBrush}" TargetName="Border"/>
  93. </Trigger>
  94. <Trigger Property="IsEnabled" Value="true"/>
  95. <Trigger Property="IsEnabled" Value="false">
  96. <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
  97. <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
  98. <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
  99. </Trigger>
  100. </ControlTemplate.Triggers>
  101. </ControlTemplate>
  102. </Setter.Value>
  103. </Setter>
  104. </Style>
  105. <!-- Simple ComboBox Toggle Button - This is used in ComboBox to expand and collapse the ComboBox Popup-->
  106. <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
  107. <Grid>
  108. <Grid.ColumnDefinitions>
  109. <ColumnDefinition/>
  110. <ColumnDefinition Width="20"/>
  111. </Grid.ColumnDefinitions>
  112. <Rectangle Grid.ColumnSpan="2" HorizontalAlignment="Stretch" x:Name="Rectangle" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="5" RadiusY="5" Fill="{DynamicResource NormalBrush}" Stroke="{DynamicResource NormalBorderBrush}"/>
  113. <Rectangle Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="5" RadiusY="5" Fill="{DynamicResource WindowBackgroundBrush}" Stroke="{DynamicResource NormalBorderBrush}"/>
  114. <Path Grid.Column="1" HorizontalAlignment="Center" x:Name="Arrow" VerticalAlignment="Center" Fill="{DynamicResource GlyphBrush}" Data="M 0 0 L 4 4 L 8 0 Z"/>
  115. </Grid>
  116. <ControlTemplate.Triggers>
  117. <Trigger Property="IsMouseOver" Value="true">
  118. <Setter Property="Fill" Value="{DynamicResource MouseOverBrush}" TargetName="Rectangle"/>
  119. </Trigger>
  120. <Trigger Property="IsChecked" Value="true">
  121. <Setter Property="Fill" Value="{DynamicResource PressedBrush}" TargetName="Rectangle"/>
  122. </Trigger>
  123. <Trigger Property="IsEnabled" Value="False">
  124. <Setter Property="Fill" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Rectangle"/>
  125. <Setter Property="Stroke" Value="{DynamicResource DisabledBorderBrush}" TargetName="Rectangle"/>
  126. <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
  127. <Setter Property="Fill" Value="{DynamicResource DisabledForegroundBrush}" TargetName="Arrow"/>
  128. </Trigger>
  129. </ControlTemplate.Triggers>
  130. </ControlTemplate>
  131. <!-- This is the area which contains the selected item in the ComboBox -->
  132. <ControlTemplate x:Key="ComboBoxTextBox" TargetType="{x:Type TextBox}">
  133. <!-- This must be named as PART_ContentHost -->
  134. <Border x:Name="PART_ContentHost" Focusable="False" Background="{TemplateBinding Background}"/>
  135. </ControlTemplate>
  136. <!-- Simple ComboBox
  137. This uses the ComboBoxToggleButton to expand and collapse a Popup control
  138. SimpleScrollViewer to allow items to be scrolled and SimpleComboBoxItem to define the look of each item
  139. The Popup shows a list of items in a StackPanel-->
  140. <Style x:Key="SimpleComboBox" TargetType="{x:Type ComboBox}">
  141. <Setter Property="SnapsToDevicePixels" Value="true"/>
  142. <Setter Property="Template">
  143. <Setter.Value>
  144. <ControlTemplate TargetType="{x:Type ComboBox}">
  145. <Grid>
  146. <!-- The ToggleButton is databound to the ComboBox itself to toggle IsDropDownOpen -->
  147. <ToggleButton Grid.Column="2" Template="{DynamicResource ComboBoxToggleButton}" x:Name="ToggleButton" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
  148. <ContentPresenter HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="ContentSite" VerticalAlignment="Center" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" IsHitTestVisible="False"/>
  149. <!-- The TextBox must be named PART_EditableTextBox or ComboBox will not recognize it -->
  150. <TextBox Visibility="Hidden" Template="{DynamicResource ComboBoxTextBox}" HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="PART_EditableTextBox" Style="{x:Null}" VerticalAlignment="Center" Focusable="True" Background="Transparent" IsReadOnly="{TemplateBinding IsReadOnly}"/>
  151. <!-- The Popup shows the list of items in the ComboBox. IsOpen is databound to IsDropDownOpen which is toggled via the ComboBoxToggleButton -->
  152. <Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide">
  153. <Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">
  154. <Border x:Name="DropDownBorder" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1"/>
  155. <ScrollViewer Margin="4,6,4,6" Style="{DynamicResource SimpleScrollViewer}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
  156. <!-- The StackPanel is used to display the children by setting IsItemsHost to be True -->
  157. <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained"/>
  158. </ScrollViewer>
  159. </Grid>
  160. </Popup>
  161. </Grid>
  162. <ControlTemplate.Triggers>
  163. <!-- This forces the DropDown to have a minimum size if it is empty -->
  164. <Trigger Property="HasItems" Value="false">
  165. <Setter Property="MinHeight" Value="95" TargetName="DropDownBorder"/>
  166. </Trigger>
  167. <Trigger Property="IsEnabled" Value="false">
  168. <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
  169. </Trigger>
  170. <Trigger Property="IsGrouping" Value="true">
  171. <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
  172. </Trigger>
  173. <Trigger Property="AllowsTransparency" SourceName="Popup" Value="true">
  174. <Setter Property="CornerRadius" Value="4" TargetName="DropDownBorder"/>
  175. <Setter Property="Margin" Value="0,2,0,0" TargetName="DropDownBorder"/>
  176. </Trigger>
  177. <Trigger Property="IsEditable" Value="true">
  178. <Setter Property="IsTabStop" Value="false"/>
  179. <Setter Property="Visibility" Value="Visible" TargetName="PART_EditableTextBox"/>
  180. <Setter Property="Visibility" Value="Hidden" TargetName="ContentSite"/>
  181. </Trigger>
  182. </ControlTemplate.Triggers>
  183. </ControlTemplate>
  184. </Setter.Value>
  185. </Setter>
  186. </Style>
  187. <!-- Simple ComboBoxItem - This is used for each item inside of the ComboBox. You can change the selected color of each item below-->
  188. <Style x:Key="SimpleComboBoxItem" d:IsControlPart="True" TargetType="{x:Type ComboBoxItem}">
  189. <Setter Property="SnapsToDevicePixels" Value="true"/>
  190. <Setter Property="Template">
  191. <Setter.Value>
  192. <ControlTemplate TargetType="{x:Type ComboBoxItem}">
  193. <Grid SnapsToDevicePixels="true">
  194. <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
  195. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  196. </Grid>
  197. <ControlTemplate.Triggers>
  198. <!-- Change IsHighlighted SelectedBackgroundBrush to set the selection color for the items -->
  199. <Trigger Property="IsHighlighted" Value="true">
  200. <Setter Property="Background" Value="{DynamicResource SelectedBackgroundBrush}" TargetName="Border"/>
  201. </Trigger>
  202. <Trigger Property="IsEnabled" Value="false">
  203. <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
  204. </Trigger>
  205. </ControlTemplate.Triggers>
  206. </ControlTemplate>
  207. </Setter.Value>
  208. </Setter>
  209. </Style>
  210. <!-- Simple TextBox -->
  211. <Style x:Key="SimpleTextBox" TargetType="{x:Type TextBox}">
  212. <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
  213. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  214. <Setter Property="AllowDrop" Value="true"/>
  215. <Setter Property="Template">
  216. <Setter.Value>
  217. <ControlTemplate TargetType="{x:Type TextBox}">
  218. <Grid>
  219. <Border x:Name="Border" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1" Padding="2" CornerRadius="2">
  220. <!-- The implementation places the Content into the ScrollViewer. It must be named PART_ContentHost for the control to function -->
  221. <ScrollViewer Margin="0" x:Name="PART_ContentHost" Style="{DynamicResource SimpleScrollViewer}" Background="{TemplateBinding Background}"/>
  222. </Border>
  223. </Grid>
  224. <ControlTemplate.Triggers>
  225. <Trigger Property="IsEnabled" Value="False">
  226. <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
  227. <Setter Property="BorderBrush" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
  228. <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
  229. </Trigger>
  230. </ControlTemplate.Triggers>
  231. </ControlTemplate>
  232. </Setter.Value>
  233. </Setter>
  234. </Style>
  235. <!-- Simple Label - This template is just a ContentPresenter that shows the content of the Label -->
  236. <Style x:Key="SimpleLabel" TargetType="{x:Type Label}">
  237. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  238. <Setter Property="VerticalContentAlignment" Value="Top"/>
  239. <Setter Property="Template">
  240. <Setter.Value>
  241. <ControlTemplate TargetType="{x:Type Label}">
  242. <Grid>
  243. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
  244. </Grid>
  245. <ControlTemplate.Triggers>
  246. <Trigger Property="IsEnabled" Value="false"/>
  247. </ControlTemplate.Triggers>
  248. </ControlTemplate>
  249. </Setter.Value>
  250. </Setter>
  251. </Style>
  252. <!-- Simple Separator - This template is used for a Separator in a menu -->
  253. <Style x:Key="SimpleSeparator" TargetType="{x:Type Separator}">
  254. <Setter Property="Height" Value="1"/>
  255. <Setter Property="Margin" Value="0,2,0,2"/>
  256. <Setter Property="Focusable" Value="false"/>
  257. <Setter Property="Template">
  258. <Setter.Value>
  259. <ControlTemplate TargetType="{x:Type Separator}">
  260. <Border BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1"/>
  261. </ControlTemplate>
  262. </Setter.Value>
  263. </Setter>
  264. </Style>
  265. <!-- Simple TabControl
  266. This template uses Simple TabItem for each Tab. The TabItems are placed in the TabPanel
  267. Limitations : The Simple TabControl only allow the Tabs to be shown at the top of the Tab control. You can re-position the TabPanel to change this-->
  268. <Style x:Key="SimpleTabControl" TargetType="{x:Type TabControl}">
  269. <Setter Property="Template">
  270. <Setter.Value>
  271. <ControlTemplate TargetType="{x:Type TabControl}">
  272. <Grid KeyboardNavigation.TabNavigation="Local">
  273. <Grid.RowDefinitions>
  274. <RowDefinition Height="Auto"/>
  275. <RowDefinition Height="*"/>
  276. </Grid.RowDefinitions>
  277. <!-- TabPanel is a layout container which allows the TabItems to wrap and re-order when selected
  278. The implementation knows to use this control because it is marked IsItemsHost = True -->
  279. <TabPanel Grid.Row="0" Margin="0,0,4,-1" x:Name="HeaderPanel" Background="Transparent" IsItemsHost="True" Panel.ZIndex="1" KeyboardNavigation.TabIndex="1"/>
  280. <Border Grid.Row="1" x:Name="Border" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1" CornerRadius="2" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabNavigation="Local" KeyboardNavigation.TabIndex="2">
  281. <!-- The implementation switches the content. This control must be named PART_SelectedContentHost -->
  282. <ContentPresenter Margin="4" x:Name="PART_SelectedContentHost" ContentSource="SelectedContent"/>
  283. </Border>
  284. </Grid>
  285. <ControlTemplate.Triggers>
  286. <Trigger Property="IsEnabled" Value="False">
  287. <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
  288. <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
  289. </Trigger>
  290. </ControlTemplate.Triggers>
  291. </ControlTemplate>
  292. </Setter.Value>
  293. </Setter>
  294. </Style>
  295. <!--Simple TabItem -->
  296. <Style x:Key="SimpleTabItem" d:IsControlPart="True" TargetType="{x:Type TabItem}">
  297. <Setter Property="Template">
  298. <Setter.Value>
  299. <ControlTemplate TargetType="{x:Type TabItem}">
  300. <Grid>
  301. <Border Margin="0,0,-4,0" x:Name="Border" Background="{DynamicResource LightBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1,1,1,1" CornerRadius="2,12,0,0">
  302. <ContentPresenter HorizontalAlignment="Center" Margin="12,2,12,2" x:Name="ContentSite" VerticalAlignment="Center" RecognizesAccessKey="True" ContentSource="Header"/>
  303. </Border>
  304. </Grid>
  305. <ControlTemplate.Triggers>
  306. <Trigger Property="IsSelected" Value="True">
  307. <Setter Property="Panel.ZIndex" Value="100"/>
  308. <Setter Property="Background" Value="{DynamicResource WindowBackgroundBrush}" TargetName="Border"/>
  309. <Setter Property="BorderThickness" Value="1,1,1,0" TargetName="Border"/>
  310. </Trigger>
  311. <Trigger Property="IsEnabled" Value="False">
  312. <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
  313. <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
  314. <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
  315. </Trigger>
  316. </ControlTemplate.Triggers>
  317. </ControlTemplate>
  318. </Setter.Value>
  319. </Setter>
  320. </Style>
  321. </ResourceDictionary>