PageRenderTime 28ms CodeModel.GetById 21ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 1ms

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