0024355: Compiler Warning level 4 for MFC samples
[occt.git] / samples / CSharp / WPF / Simple Styles.xaml
CommitLineData
d1a2fee8 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 <Style TargetType="{x:Type Image}" x:Key="toolbarImageStyle">
84 <Style.Triggers>
85 <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
86 <Setter Property="Opacity" Value="0.50"></Setter>
87 </DataTrigger>
88 </Style.Triggers>
89 </Style>
90
91 <Style TargetType="MenuItem" x:Key="popupItem">
92 <Setter Property="CommandTarget"
93 Value="{Binding Path=PlacementTarget, RelativeSource={RelativeSource AncestorType=ContextMenu} }"/>
94 </Style>
95
96 <!-- Simple Button - This control sets brushes on each state. Note that these brushes must be listed above since they are static resources -->
97 <Style x:Key="SimpleButton" TargetType="{x:Type Button}" BasedOn="{x:Null}">
98 <Setter Property="FocusVisualStyle" Value="{DynamicResource SimpleButtonFocusVisual}"/>
99 <Setter Property="Background" Value="{DynamicResource NormalBrush}"/>
100 <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
101 <Setter Property="Template">
102 <Setter.Value>
103 <ControlTemplate TargetType="{x:Type Button}">
104
105 <!-- We use Grid as a root because it is easy to add more elements to customize the button -->
106 <Grid x:Name="Grid">
107 <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"/>
108
109 <!-- Content Presenter is where the text content etc is placed by the control -->
110 <!-- The bindings are useful so that the control can be parameterized without editing the template -->
111 <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
112 </Grid>
113
114 <!--Each state sets a brush on the Border in the template -->
115 <ControlTemplate.Triggers>
116 <Trigger Property="IsKeyboardFocused" Value="true">
117 <Setter Property="BorderBrush" Value="{DynamicResource DefaultedBorderBrush}" TargetName="Border"/>
118 </Trigger>
119 <Trigger Property="IsMouseOver" Value="true">
120 <Setter Property="Background" Value="{DynamicResource MouseOverBrush}" TargetName="Border"/>
121 </Trigger>
122 <Trigger Property="IsPressed" Value="true">
123 <Setter Property="Background" Value="{DynamicResource PressedBrush}" TargetName="Border"/>
124 <Setter Property="BorderBrush" Value="{DynamicResource PressedBorderBrush}" TargetName="Border"/>
125 </Trigger>
126 <Trigger Property="IsEnabled" Value="true"/>
127 <Trigger Property="IsEnabled" Value="false">
128 <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
129 <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
130 <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
131 </Trigger>
132 </ControlTemplate.Triggers>
133 </ControlTemplate>
134 </Setter.Value>
135 </Setter>
136 </Style>
137
138 <Style x:Key="RadioButtonFocusVisual">
139 <Setter Property="Control.Template">
140 <Setter.Value>
141 <ControlTemplate>
142 <Border>
143 <Rectangle Margin="15,0,0,0" Stroke="#60000000" StrokeThickness="1" StrokeDashArray="1 2"/>
144 </Border>
145 </ControlTemplate>
146 </Setter.Value>
147 </Setter>
148 </Style>
149
150 <Style x:Key="CheckBoxFocusVisual">
151 <Setter Property="Control.Template">
152 <Setter.Value>
153 <ControlTemplate>
154 <Border>
155 <Rectangle Margin="15,0,0,0" Stroke="#60000000" StrokeThickness="1" StrokeDashArray="1 2"/>
156 </Border>
157 </ControlTemplate>
158 </Setter.Value>
159 </Setter>
160 </Style>
161
162 <!-- Simple CheckBox -->
163 <Style x:Key="SimpleCheckBox" TargetType="{x:Type CheckBox}">
164 <Setter Property="SnapsToDevicePixels" Value="true"/>
165 <Setter Property="FocusVisualStyle" Value="{DynamicResource CheckBoxFocusVisual}"/>
166 <Setter Property="Background" Value="{DynamicResource NormalBrush}"/>
167 <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
168 <Setter Property="Template">
169 <Setter.Value>
170 <ControlTemplate TargetType="{x:Type CheckBox}">
171
172 <!-- BulletDecorator is used to provide baseline alignment between the checkmark and the Content -->
173 <BulletDecorator Background="Transparent">
174 <BulletDecorator.Bullet>
175 <Grid Width="13" Height="13">
176 <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
177 <Path x:Name="CheckMark" Stroke="{DynamicResource GlyphBrush}" StrokeThickness="2" SnapsToDevicePixels="False" Data="M 0 0 L 13 13 M 0 13 L 13 0"/>
178 </Grid>
179 </BulletDecorator.Bullet>
180 <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
181 </BulletDecorator>
182
183 <!-- This uses Visibility to hide and show the CheckMark on IsChecked -->
184 <ControlTemplate.Triggers>
185 <Trigger Property="IsChecked" Value="false">
186 <Setter Property="Visibility" Value="Collapsed" TargetName="CheckMark"/>
187 </Trigger>
188 <Trigger Property="IsMouseOver" Value="true">
189 <Setter Property="Background" Value="{DynamicResource MouseOverBrush}" TargetName="Border"/>
190 </Trigger>
191 <Trigger Property="IsPressed" Value="true">
192 <Setter Property="Background" Value="{DynamicResource PressedBrush}" TargetName="Border"/>
193 <Setter Property="BorderBrush" Value="{DynamicResource PressedBorderBrush}" TargetName="Border"/>
194 </Trigger>
195 <Trigger Property="IsEnabled" Value="false">
196 <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
197 <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
198 </Trigger>
199 </ControlTemplate.Triggers>
200
201 </ControlTemplate>
202 </Setter.Value>
203 </Setter>
204 </Style>
205
206 <!-- Simple Radio Button -->
207 <Style x:Key="SimpleRadioButton" TargetType="{x:Type RadioButton}">
208 <Setter Property="SnapsToDevicePixels" Value="true"/>
209 <Setter Property="FocusVisualStyle" Value="{DynamicResource RadioButtonFocusVisual}"/>
210 <Setter Property="Background" Value="{DynamicResource NormalBrush}"/>
211 <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
212 <Setter Property="Template">
213 <Setter.Value>
214 <ControlTemplate TargetType="{x:Type RadioButton}">
215
216 <!-- BulletDecorator is used to provide baseline alignment between the checkmark and the Content -->
217 <BulletDecorator Background="Transparent">
218 <BulletDecorator.Bullet>
219 <Grid Width="13" Height="13">
220 <Ellipse x:Name="Ellipse_Border" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1"/>
221 <Ellipse Margin="4" x:Name="CheckMark" Fill="{DynamicResource GlyphBrush}"/>
222 </Grid>
223 </BulletDecorator.Bullet>
224 <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
225 </BulletDecorator>
226
227 <ControlTemplate.Triggers>
228 <Trigger Property="IsChecked" Value="false">
229 <Setter Property="Visibility" Value="Collapsed" TargetName="CheckMark"/>
230 </Trigger>
231 <Trigger Property="IsMouseOver" Value="true">
232 <Setter Property="Fill" Value="{DynamicResource MouseOverBrush}" TargetName="Ellipse_Border"/>
233 </Trigger>
234 <Trigger Property="IsPressed" Value="true">
235 <Setter Property="Fill" Value="{DynamicResource PressedBrush}" TargetName="Ellipse_Border"/>
236 <Setter Property="Stroke" Value="{DynamicResource GlyphBrush}" TargetName="Ellipse_Border"/>
237 </Trigger>
238 <Trigger Property="IsEnabled" Value="false">
239 <Setter Property="Fill" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Ellipse_Border"/>
240 <Setter Property="Stroke" Value="#40000000" TargetName="Ellipse_Border"/>
241 <Setter Property="Foreground" Value="#80000000"/>
242 </Trigger>
243
244 </ControlTemplate.Triggers>
245 </ControlTemplate>
246 </Setter.Value>
247 </Setter>
248 </Style>
249
250 <!-- Simple Repeat Button - This is used by Simple ScrollBar for the up and down buttons -->
251 <Style x:Key="SimpleRepeatButton" d:IsControlPart="True" TargetType="{x:Type RepeatButton}" BasedOn="{x:Null}">
252 <Setter Property="Background" Value="{DynamicResource NormalBrush}"/>
253 <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
254 <Setter Property="Template">
255 <Setter.Value>
256 <ControlTemplate TargetType="{x:Type RepeatButton}">
257 <Grid>
258 <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
259 <ContentPresenter HorizontalAlignment="Center" x:Name="ContentPresenter" VerticalAlignment="Center" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
260 </Grid>
261 <ControlTemplate.Triggers>
262 <Trigger Property="IsKeyboardFocused" Value="true">
263 <Setter Property="BorderBrush" Value="{DynamicResource DefaultedBorderBrush}" TargetName="Border"/>
264 </Trigger>
265 <Trigger Property="IsMouseOver" Value="true">
266 <Setter Property="Background" Value="{DynamicResource MouseOverBrush}" TargetName="Border"/>
267 </Trigger>
268 <Trigger Property="IsPressed" Value="true">
269 <Setter Property="Background" Value="{DynamicResource PressedBrush}" TargetName="Border"/>
270 <Setter Property="BorderBrush" Value="{DynamicResource PressedBorderBrush}" TargetName="Border"/>
271 </Trigger>
272 <Trigger Property="IsEnabled" Value="false">
273 <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
274 <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
275 <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
276 </Trigger>
277 </ControlTemplate.Triggers>
278 </ControlTemplate>
279 </Setter.Value>
280 </Setter>
281 </Style>
282
283 <!-- Simple Thumb - The Thumb is the draggable part of the Scrollbar -->
284 <Style x:Key="SimpleThumbStyle" d:IsControlPart="True" TargetType="{x:Type Thumb}" BasedOn="{x:Null}">
285 <Setter Property="Template">
286 <Setter.Value>
287 <ControlTemplate TargetType="{x:Type Thumb}">
288 <Grid Margin="0,0,0,0" x:Name="Grid">
289 <Rectangle HorizontalAlignment="Stretch" x:Name="Rectangle" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="2" RadiusY="2" Fill="{DynamicResource NormalBrush}" Stroke="{DynamicResource NormalBorderBrush}"/>
290 </Grid>
291 <ControlTemplate.Triggers>
292 <Trigger Property="IsFocused" Value="True"/>
293 <Trigger Property="IsMouseOver" Value="True"/>
294 <Trigger Property="IsEnabled" Value="False"/>
295 <Trigger Property="IsDragging" Value="True"/>
296 </ControlTemplate.Triggers>
297 </ControlTemplate>
298 </Setter.Value>
299 </Setter>
300 </Style>
301
302 <!-- Simple ScrollRepeatButton Style - This RepeatButton is used above and below the Thumb in the Scrollbar. They are set to transparent si that they do not show over the scrollbar -->
303 <Style x:Key="SimpleScrollRepeatButtonStyle" d:IsControlPart="True" TargetType="{x:Type RepeatButton}">
304 <Setter Property="Background" Value="Transparent"/>
305 <Setter Property="BorderBrush" Value="Transparent"/>
306 <Setter Property="IsTabStop" Value="false"/>
307 <Setter Property="Focusable" Value="false"/>
308 <Setter Property="Template">
309 <Setter.Value>
310 <ControlTemplate TargetType="{x:Type RepeatButton}">
311 <Grid>
312 <Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"/>
313 </Grid>
314 </ControlTemplate>
315 </Setter.Value>
316 </Setter>
317 </Style>
318
319 <!-- Simple ScrollBar This makes use of SimpleThumb, SimpleRepeatButton and SimpleScrollRepeatButton -->
320
321 <Style x:Key="SimpleScrollBar" TargetType="{x:Type ScrollBar}">
322 <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
323 <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
324 <Setter Property="Template">
325 <Setter.Value>
326 <ControlTemplate TargetType="{x:Type ScrollBar}">
327 <Grid x:Name="GridRoot" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Background="{TemplateBinding Background}">
328 <Grid.RowDefinitions>
329 <RowDefinition MaxHeight="18"/>
330 <RowDefinition Height="0.00001*"/>
331 <RowDefinition MaxHeight="18"/>
332 </Grid.RowDefinitions>
333
334 <RepeatButton x:Name="DecreaseRepeat" Style="{DynamicResource SimpleRepeatButton}" Command="ScrollBar.LineUpCommand">
335 <Grid>
336 <Path x:Name="DecreaseArrow" Stroke="{TemplateBinding Foreground}" StrokeThickness="1" Data="M 0 4 L 8 4 L 4 0 Z"/>
337 </Grid>
338 </RepeatButton>
339
340 <!-- Track is a special layout container which sizes the thumb and the repeat button which do jump scrolling either side of it -->
341 <Track Grid.Row="1" x:Name="PART_Track" Orientation="Vertical" IsDirectionReversed="true">
342 <Track.Thumb>
343 <Thumb Style="{DynamicResource SimpleThumbStyle}"/>
344 </Track.Thumb>
345 <Track.IncreaseRepeatButton>
346 <RepeatButton x:Name="PageUp" Style="{DynamicResource SimpleScrollRepeatButtonStyle}" Command="ScrollBar.PageDownCommand"/>
347 </Track.IncreaseRepeatButton>
348 <Track.DecreaseRepeatButton>
349 <RepeatButton x:Name="PageDown" Style="{DynamicResource SimpleScrollRepeatButtonStyle}" Command="ScrollBar.PageUpCommand"/>
350 </Track.DecreaseRepeatButton>
351 </Track>
352
353 <RepeatButton Grid.Row="2" x:Name="IncreaseRepeat" Style="{DynamicResource SimpleRepeatButton}" Command="ScrollBar.LineDownCommand">
354 <Grid>
355 <Path x:Name="IncreaseArrow" Stroke="{TemplateBinding Foreground}" StrokeThickness="1" Data="M 0 0 L 4 4 L 8 0 Z"/>
356 </Grid>
357 </RepeatButton>
358 </Grid>
359
360 <!-- This uses a single template for ScrollBar and rotate it to be Horizontal
361 It also changes the commands so that the it does Left and Right instead of Up and Down Commands -->
362 <ControlTemplate.Triggers>
363 <Trigger Property="Orientation" Value="Horizontal">
364
365 <!-- Rotate the ScrollBar from Vertical to Horizontal -->
366 <Setter Property="LayoutTransform" TargetName="GridRoot">
367 <Setter.Value>
368 <RotateTransform Angle="-90"/>
369 </Setter.Value>
370 </Setter>
371
372 <!-- Track is bound to Orientation internally, so we need to rotate it back to Vertical -->
373 <Setter TargetName="PART_Track" Property="Orientation" Value="Vertical"/>
374
375 <!-- Change the commands to do Horizontal commands -->
376 <Setter Property="Command" Value="ScrollBar.LineLeftCommand" TargetName="DecreaseRepeat"/>
377 <Setter Property="Command" Value="ScrollBar.LineRightCommand" TargetName="IncreaseRepeat"/>
378 <Setter Property="Command" Value="ScrollBar.PageLeftCommand" TargetName="PageDown"/>
379 <Setter Property="Command" Value="ScrollBar.PageRightCommand" TargetName="PageUp"/>
380 </Trigger>
381 </ControlTemplate.Triggers>
382 </ControlTemplate>
383 </Setter.Value>
384 </Setter>
385 </Style>
386
387 <!-- Simple ScrollViewer
388 ScrollViewer is a Grid control which has a ContentPresenter and a Horizontal and Vertical ScrollBar
389 It is used by ListBox, MenuItem, ComboBox, and TreeView -->
390 <Style x:Key="SimpleScrollViewer" TargetType="{x:Type ScrollViewer}" BasedOn="{x:Null}">
391 <Setter Property="Template">
392 <Setter.Value>
393 <ControlTemplate TargetType="{x:Type ScrollViewer}">
394 <Grid Background="{TemplateBinding Background}">
395 <Grid.ColumnDefinitions>
396 <ColumnDefinition Width="*"/>
397 <ColumnDefinition Width="Auto"/>
398 </Grid.ColumnDefinitions>
399 <Grid.RowDefinitions>
400 <RowDefinition Height="*"/>
401 <RowDefinition Height="Auto"/>
402 </Grid.RowDefinitions>
403 <ScrollContentPresenter Grid.Column="0" Grid.Row="0" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}"/>
404
405 <!-- The visibility of the ScrollBars is controlled by the implementation fo the control -->
406 <ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Grid.Column="0" Grid.Row="1" x:Name="PART_HorizontalScrollBar" Style="{DynamicResource SimpleScrollBar}" Orientation="Horizontal" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}" Minimum="0" Maximum="{TemplateBinding ScrollableWidth}" />
407 <ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Grid.Column="1" Grid.Row="0" x:Name="PART_VerticalScrollBar" Style="{DynamicResource SimpleScrollBar}" Orientation="Vertical" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Minimum="0" Maximum="{TemplateBinding ScrollableHeight}" />
408 </Grid>
409 </ControlTemplate>
410 </Setter.Value>
411 </Setter>
412 </Style>
413
414 <!-- Simple ListBox - This uses SimpleScrollViewer to allow items to be scrolled and SimpleListBoxItem to define the look of each item -->
415 <Style x:Key="SimpleListBox" TargetType="{x:Type ListBox}">
416 <Setter Property="SnapsToDevicePixels" Value="true"/>
417 <Setter Property="Background" Value="{DynamicResource WindowBackgroundBrush}"/>
418 <Setter Property="BorderBrush" Value="{DynamicResource SolidBorderBrush}"/>
419 <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
420 <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
421 <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
422 <Setter Property="Template">
423 <Setter.Value>
424 <ControlTemplate TargetType="{x:Type ListBox}">
425 <Grid>
426 <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
427 <ScrollViewer Margin="1" Style="{DynamicResource SimpleScrollViewer}" Focusable="false" Background="{TemplateBinding Background}">
428
429 <!-- The StackPanel is used to display the children by setting IsItemsHost to be Trus -->
430 <StackPanel Margin="2" IsItemsHost="true"/>
431
432 </ScrollViewer>
433 </Grid>
434 <ControlTemplate.Triggers>
435 <Trigger Property="IsEnabled" Value="false">
436 <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
437 <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
438 </Trigger>
439 <Trigger Property="IsGrouping" Value="true">
440 <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
441 </Trigger>
442 </ControlTemplate.Triggers>
443 </ControlTemplate>
444 </Setter.Value>
445 </Setter>
446 </Style>
447
448 <!-- Simple ListBoxItem - This is used for each Item in a ListBox. The item's content is placed in the ContentPresenter -->
449
450 <Style x:Key="SimpleListBoxItem" d:IsControlPart="True" TargetType="{x:Type ListBoxItem}">
451 <Setter Property="SnapsToDevicePixels" Value="true"/>
452 <Setter Property="OverridesDefaultStyle" Value="true"/>
453 <Setter Property="Template">
454 <Setter.Value>
455 <ControlTemplate TargetType="{x:Type ListBoxItem}">
456 <Grid SnapsToDevicePixels="true">
457 <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
458 <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
459 </Grid>
460 <ControlTemplate.Triggers>
461
462 <!-- Change IsSelected SelectedBackgroundBrush to set the selection color for the items -->
463 <Trigger Property="IsSelected" Value="true">
464 <Setter Property="Background" Value="{DynamicResource SelectedBackgroundBrush}" TargetName="Border"/>
465 </Trigger>
466
467 <Trigger Property="IsEnabled" Value="false">
468 <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
469 </Trigger>
470 </ControlTemplate.Triggers>
471 </ControlTemplate>
472 </Setter.Value>
473 </Setter>
474 </Style>
475
476 <!-- Simple Expander ToggleButton - This Button is used by the Expander control. When it is toggled it switches visibility on the Up_Arrow and Down_Arrow -->
477 <ControlTemplate x:Key="ExpanderToggleButton" TargetType="{x:Type ToggleButton}">
478 <Grid>
479 <Rectangle Margin="0,0,0,0" x:Name="Rectangle" Fill="Transparent" Stroke="{DynamicResource NormalBorderBrush}"/>
480 <Path HorizontalAlignment="Center" x:Name="Up_Arrow" VerticalAlignment="Center" Fill="{DynamicResource GlyphBrush}" Data="M 0 0 L 4 4 L 8 0 Z"/>
481 <Path Visibility="Collapsed" HorizontalAlignment="Center" x:Name="Down_Arrow" VerticalAlignment="Center" Fill="{DynamicResource GlyphBrush}" Data="M 0 4 L 4 0 L 8 4 Z"/>
482 </Grid>
483 <ControlTemplate.Triggers>
484 <Trigger Property="IsMouseOver" Value="true">
485 <Setter Property="Fill" Value="{DynamicResource MouseOverBrush}" TargetName="Rectangle"/>
486 </Trigger>
487 <Trigger Property="IsPressed" Value="true">
488 <Setter Property="Fill" Value="{DynamicResource PressedBrush}" TargetName="Rectangle"/>
489 </Trigger>
490 <Trigger Property="IsChecked" Value="true">
491 <Setter Property="Visibility" Value="Visible" TargetName="Down_Arrow"/>
492 <Setter Property="Visibility" Value="Collapsed" TargetName="Up_Arrow"/>
493 </Trigger>
494 <Trigger Property="IsEnabled" Value="False">
495 <Setter Property="Fill" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Rectangle"/>
496 <Setter Property="Stroke" Value="{DynamicResource DisabledBorderBrush}" TargetName="Rectangle"/>
497 <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
498 <Setter Property="Fill" Value="{DynamicResource DisabledForegroundBrush}" TargetName="Up_Arrow"/>
499 </Trigger>
500 </ControlTemplate.Triggers>
501 </ControlTemplate>
502
503 <!-- Simple Expander
504 This uses the Simpler ExpanderToggleButton. It sets Visibility on the ContentPresenter to expand
505 Limitations : The Simple Expander only expands down -->
506 <Style x:Key="SimpleExpander" TargetType="{x:Type Expander}">
507 <Setter Property="Background" Value="{DynamicResource LightBrush}"/>
508 <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
509 <Setter Property="Template">
510 <Setter.Value>
511 <ControlTemplate TargetType="{x:Type Expander}">
512 <Grid>
513 <Grid.RowDefinitions>
514 <RowDefinition Height="Auto"/>
515 <RowDefinition Height="*" x:Name="ContentRow"/>
516 </Grid.RowDefinitions>
517 <Border Grid.Row="0" x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2,2,0,0">
518 <Grid>
519 <Grid.ColumnDefinitions>
520 <ColumnDefinition Width="20"/>
521 <ColumnDefinition Width="*"/>
522 </Grid.ColumnDefinitions>
523 <ToggleButton Template="{DynamicResource ExpanderToggleButton}" Background="{DynamicResource NormalBrush}" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" OverridesDefaultStyle="True"/>
524 <ContentPresenter Grid.Column="1" Margin="4" RecognizesAccessKey="True" ContentSource="Header"/>
525 </Grid>
526 </Border>
527 <Border Visibility="Collapsed" Grid.Row="1" x:Name="ExpandSite" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1,0,1,1" CornerRadius="0,0,2,2">
528 <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Focusable="false"/>
529 </Border>
530 </Grid>
531 <ControlTemplate.Triggers>
532 <Trigger Property="IsExpanded" Value="True">
533 <Setter Property="Visibility" Value="Visible" TargetName="ExpandSite"/>
534 </Trigger>
535 <Trigger Property="IsEnabled" Value="False">
536 <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
537 <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
538 <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
539 </Trigger>
540 </ControlTemplate.Triggers>
541 </ControlTemplate>
542 </Setter.Value>
543 </Setter>
544 </Style>
545
546 <!-- Simple ComboBox Toggle Button - This is used in ComboBox to expand and collapse the ComboBox Popup-->
547 <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
548 <Grid>
549 <Grid.ColumnDefinitions>
550 <ColumnDefinition/>
551 <ColumnDefinition Width="20"/>
552 </Grid.ColumnDefinitions>
553 <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}"/>
554 <Rectangle Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="5" RadiusY="5" Fill="{DynamicResource WindowBackgroundBrush}" Stroke="{DynamicResource NormalBorderBrush}"/>
555 <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"/>
556 </Grid>
557 <ControlTemplate.Triggers>
558 <Trigger Property="IsMouseOver" Value="true">
559 <Setter Property="Fill" Value="{DynamicResource MouseOverBrush}" TargetName="Rectangle"/>
560 </Trigger>
561 <Trigger Property="IsChecked" Value="true">
562 <Setter Property="Fill" Value="{DynamicResource PressedBrush}" TargetName="Rectangle"/>
563 </Trigger>
564 <Trigger Property="IsEnabled" Value="False">
565 <Setter Property="Fill" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Rectangle"/>
566 <Setter Property="Stroke" Value="{DynamicResource DisabledBorderBrush}" TargetName="Rectangle"/>
567 <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
568 <Setter Property="Fill" Value="{DynamicResource DisabledForegroundBrush}" TargetName="Arrow"/>
569 </Trigger>
570 </ControlTemplate.Triggers>
571 </ControlTemplate>
572
573 <!-- This is the area which contains the selected item in the ComboBox -->
574
575 <ControlTemplate x:Key="ComboBoxTextBox" TargetType="{x:Type TextBox}">
576 <!-- This must be named as PART_ContentHost -->
577 <Border x:Name="PART_ContentHost" Focusable="False" Background="{TemplateBinding Background}"/>
578 </ControlTemplate>
579
580 <!-- Simple ComboBox
581 This uses the ComboBoxToggleButton to expand and collapse a Popup control
582 SimpleScrollViewer to allow items to be scrolled and SimpleComboBoxItem to define the look of each item
583 The Popup shows a list of items in a StackPanel-->
584
585 <Style x:Key="SimpleComboBox" TargetType="{x:Type ComboBox}">
586 <Setter Property="SnapsToDevicePixels" Value="true"/>
587 <Setter Property="Template">
588 <Setter.Value>
589 <ControlTemplate TargetType="{x:Type ComboBox}">
590 <Grid>
591 <!-- The ToggleButton is databound to the ComboBox itself to toggle IsDropDownOpen -->
592 <ToggleButton Grid.Column="2" Template="{DynamicResource ComboBoxToggleButton}" x:Name="ToggleButton" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
593 <ContentPresenter HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="ContentSite" VerticalAlignment="Center" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" IsHitTestVisible="False"/>
594
595 <!-- The TextBox must be named PART_EditableTextBox or ComboBox will not recognize it -->
596 <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}"/>
597
598 <!-- The Popup shows the list of items in the ComboBox. IsOpen is databound to IsDropDownOpen which is toggled via the ComboBoxToggleButton -->
599 <Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide">
600 <Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">
601 <Border x:Name="DropDownBorder" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1"/>
602 <ScrollViewer Margin="4,6,4,6" Style="{DynamicResource SimpleScrollViewer}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
603
604 <!-- The StackPanel is used to display the children by setting IsItemsHost to be True -->
605 <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained"/>
606
607 </ScrollViewer>
608 </Grid>
609 </Popup>
610 </Grid>
611 <ControlTemplate.Triggers>
612 <!-- This forces the DropDown to have a minimum size if it is empty -->
613 <Trigger Property="HasItems" Value="false">
614 <Setter Property="MinHeight" Value="95" TargetName="DropDownBorder"/>
615 </Trigger>
616 <Trigger Property="IsEnabled" Value="false">
617 <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
618 </Trigger>
619 <Trigger Property="IsGrouping" Value="true">
620 <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
621 </Trigger>
622 <Trigger Property="AllowsTransparency" SourceName="Popup" Value="true">
623 <Setter Property="CornerRadius" Value="4" TargetName="DropDownBorder"/>
624 <Setter Property="Margin" Value="0,2,0,0" TargetName="DropDownBorder"/>
625 </Trigger>
626 <Trigger Property="IsEditable" Value="true">
627 <Setter Property="IsTabStop" Value="false"/>
628 <Setter Property="Visibility" Value="Visible" TargetName="PART_EditableTextBox"/>
629 <Setter Property="Visibility" Value="Hidden" TargetName="ContentSite"/>
630 </Trigger>
631 </ControlTemplate.Triggers>
632 </ControlTemplate>
633 </Setter.Value>
634 </Setter>
635 </Style>
636
637 <!-- Simple ComboBoxItem - This is used for each item inside of the ComboBox. You can change the selected color of each item below-->
638 <Style x:Key="SimpleComboBoxItem" d:IsControlPart="True" TargetType="{x:Type ComboBoxItem}">
639 <Setter Property="SnapsToDevicePixels" Value="true"/>
640 <Setter Property="Template">
641 <Setter.Value>
642 <ControlTemplate TargetType="{x:Type ComboBoxItem}">
643 <Grid SnapsToDevicePixels="true">
644 <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
645 <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
646 </Grid>
647 <ControlTemplate.Triggers>
648
649 <!-- Change IsHighlighted SelectedBackgroundBrush to set the selection color for the items -->
650 <Trigger Property="IsHighlighted" Value="true">
651 <Setter Property="Background" Value="{DynamicResource SelectedBackgroundBrush}" TargetName="Border"/>
652 </Trigger>
653
654 <Trigger Property="IsEnabled" Value="false">
655 <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
656 </Trigger>
657 </ControlTemplate.Triggers>
658 </ControlTemplate>
659 </Setter.Value>
660 </Setter>
661 </Style>
662
663 <!-- Simple SimpleProgressBar
664 The template uses two Border controls to show the Track and Progress
665 Limitations : It only supports a horizontal orientated ProgressBar -->
666 <Style x:Key="SimpleProgressBar" TargetType="{x:Type ProgressBar}">
667 <Setter Property="Template">
668 <Setter.Value>
669 <ControlTemplate TargetType="{x:Type ProgressBar}">
670 <Grid>
671
672 <!-- This Border is the track. It must be named PART_Track -->
673 <Border x:Name="PART_Track" Background="{DynamicResource PressedBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1" CornerRadius="2"/>
674
675 <!-- This Border shows progress. It must be named PART_Indicator for the control to function -->
676 <Border HorizontalAlignment="Left" x:Name="PART_Indicator" Background="{DynamicResource MouseOverBrush}" BorderBrush="{DynamicResource NormalBorderBrush}" BorderThickness="1" CornerRadius="2"/>
677
678 </Grid>
679 </ControlTemplate>
680 </Setter.Value>
681 </Setter>
682 </Style>
683
684 <!-- Simple TextBox -->
685 <Style x:Key="SimpleTextBox" TargetType="{x:Type TextBox}">
686 <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
687 <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
688 <Setter Property="AllowDrop" Value="true"/>
689 <Setter Property="Template">
690 <Setter.Value>
691 <ControlTemplate TargetType="{x:Type TextBox}">
692 <Grid>
693 <Border x:Name="Border" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1" Padding="2" CornerRadius="2">
694
695 <!-- The implementation places the Content into the ScrollViewer. It must be named PART_ContentHost for the control to function -->
696 <ScrollViewer Margin="0" x:Name="PART_ContentHost" Style="{DynamicResource SimpleScrollViewer}" Background="{TemplateBinding Background}"/>
697
698 </Border>
699 </Grid>
700 <ControlTemplate.Triggers>
701 <Trigger Property="IsEnabled" Value="False">
702 <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
703 <Setter Property="BorderBrush" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
704 <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
705 </Trigger>
706 </ControlTemplate.Triggers>
707 </ControlTemplate>
708 </Setter.Value>
709 </Setter>
710 </Style>
711
712 <!-- Simple Label - This template is just a ContentPresenter that shows the content of the Label -->
713 <Style x:Key="SimpleLabel" TargetType="{x:Type Label}">
714 <Setter Property="HorizontalContentAlignment" Value="Left"/>
715 <Setter Property="VerticalContentAlignment" Value="Top"/>
716 <Setter Property="Template">
717 <Setter.Value>
718 <ControlTemplate TargetType="{x:Type Label}">
719 <Grid>
720 <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
721 </Grid>
722 <ControlTemplate.Triggers>
723 <Trigger Property="IsEnabled" Value="false"/>
724 </ControlTemplate.Triggers>
725 </ControlTemplate>
726 </Setter.Value>
727 </Setter>
728 </Style>
729
730 <!-- Simple Menu - This template uses a StackPanel to layout MenuItems -->
731 <Style x:Key="SimpleMenu" TargetType="{x:Type Menu}">
732 <Setter Property="Background" Value="{DynamicResource LightBrush}"/>
733 <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
734 <Setter Property="SnapsToDevicePixels" Value="True"/>
735 <Setter Property="Template">
736 <Setter.Value>
737 <ControlTemplate TargetType="{x:Type Menu}">
738 <Grid>
739 <Border Margin="1" x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
740 <StackPanel Background="{TemplateBinding Background}" IsItemsHost="True" ClipToBounds="True" Orientation="Horizontal"/>
741 </Grid>
742 <ControlTemplate.Triggers>
743 <Trigger Property="IsEnabled" Value="False">
744 <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
745 <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
746 </Trigger>
747 </ControlTemplate.Triggers>
748 </ControlTemplate>
749 </Setter.Value>
750 </Setter>
751 </Style>
752
753 <!-- This BitmapEffect is used by the Simple MenuItem -->
754 <DropShadowBitmapEffect x:Key="PopupDropShadow" ShadowDepth="1.5" Softness="0.15"/>
755
756 <!-- Simple MenuItem - The template uses triggers to provide four different arrangements of menu item which are set via the Role property -->
757 <Style x:Key="SimpleMenuItem" TargetType="{x:Type MenuItem}">
758 <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
759 <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
760 <Setter Property="Background" Value="Transparent"/>
761 <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/>
762 <Setter Property="Template">
763 <Setter.Value>
764 <ControlTemplate TargetType="{x:Type MenuItem}">
765 <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
766 <Grid>
767
768 <!-- The Grid is used to hold together columns for an Icon, Content, Glyph checkmark and Arrow to show the next level
769 Size sharing is used in Grid so that the Icon, Content, Arrow for each MenuItem align together -->
770 <Grid.ColumnDefinitions>
771 <ColumnDefinition MinWidth="17" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup"/>
772 <ColumnDefinition Width="*"/>
773 <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup"/>
774 <ColumnDefinition Width="14"/>
775 </Grid.ColumnDefinitions>
776
777 <!-- ContentPresenter to show an Icon if needed -->
778 <ContentPresenter Margin="4,0,6,0" x:Name="Icon" VerticalAlignment="Center" ContentSource="Icon"/>
779
780 <!-- Glyph is a checkmark if needed for a checkable menu -->
781 <Grid Visibility="Hidden" Margin="4,0,6,0" x:Name="GlyphPanel" VerticalAlignment="Center">
782 <Path x:Name="GlyphPanelpath" VerticalAlignment="Center" Fill="{TemplateBinding Foreground}" Data="M0,2 L0,4.8 L2.5,7.4 L7.1,2.8 L7.1,0 L2.5,4.6 z" FlowDirection="LeftToRight"/>
783 </Grid>
784
785 <!-- Content for the menu text etc -->
786 <ContentPresenter Grid.Column="1" Margin="{TemplateBinding Padding}" x:Name="HeaderHost" RecognizesAccessKey="True" ContentSource="Header"/>
787
788 <!-- Arrow drawn path which points to the next level of the menu -->
789 <Grid Grid.Column="3" Margin="4,0,6,0" x:Name="ArrowPanel" VerticalAlignment="Center">
790 <Path x:Name="ArrowPanelPath" VerticalAlignment="Center" Fill="{TemplateBinding Foreground}" Data="M0,0 L0,8 L4,4 z"/>
791 </Grid>
792
793 <!-- The Popup is the body of the menu which expands down or across depending on the level of the item -->
794 <Popup IsOpen="{Binding Path=IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Right" x:Name="SubMenuPopup" Focusable="false" AllowsTransparency="true" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" VerticalOffset="-3">
795 <Grid x:Name="SubMenu">
796 <Border x:Name="SubMenuBorder" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1"/>
797
798 <!-- StackPanel holds children of the menu. This is set bu IsItemsHost=True -->
799 <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
800 </Grid>
801 </Popup>
802
803 </Grid>
804 </Border>
805
806 <!-- These triggers re-configure the four arrangements of MenuItem to show different levels of menu via Role -->
807 <ControlTemplate.Triggers>
808
809 <!-- Role = TopLevelHeader : this is the root menu item in a menu; the Popup expands down -->
810 <Trigger Property="Role" Value="TopLevelHeader">
811 <Setter Property="Margin" Value="0,1,0,1"/>
812 <Setter Property="Padding" Value="6,3,6,3"/>
813 <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
814 <Setter Property="Placement" Value="Bottom" TargetName="SubMenuPopup"/>
815 <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel"/>
816 </Trigger>
817
818 <!-- Role = TopLevelItem : this is a child menu item from the top level without any child items-->
819 <Trigger Property="Role" Value="TopLevelItem">
820 <Setter Property="Margin" Value="0,1,0,1"/>
821 <Setter Property="Padding" Value="6,3,6,3"/>
822 <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel"/>
823 </Trigger>
824
825 <!-- Role = SubMenuHeader : this is a child menu item which does not have children -->
826 <Trigger Property="Role" Value="SubmenuHeader">
827 <Setter Property="DockPanel.Dock" Value="Top"/>
828 <Setter Property="Padding" Value="0,2,0,2"/>
829 <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
830 </Trigger>
831
832 <!-- Role = SubMenuItem : this is a child menu item which has children-->
833 <Trigger Property="Role" Value="SubmenuItem">
834 <Setter Property="DockPanel.Dock" Value="Top"/>
835 <Setter Property="Padding" Value="0,2,0,2"/>
836 <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel"/>
837 </Trigger>
838 <Trigger Property="IsSuspendingPopupAnimation" Value="true">
839 <Setter Property="PopupAnimation" Value="None" TargetName="SubMenuPopup"/>
840 </Trigger>
841
842 <!-- If no Icon is present the we collapse the Icon Content -->
843 <Trigger Property="Icon" Value="{x:Null}">
844 <Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
845 </Trigger>
846
847 <!-- The GlyphPanel contains the CheckMark -->
848 <Trigger Property="IsChecked" Value="true">
849 <Setter Property="Visibility" Value="Visible" TargetName="GlyphPanel"/>
850 <Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
851 </Trigger>
852
853 <Trigger Property="AllowsTransparency" SourceName="SubMenuPopup" Value="true">
854 <Setter Property="Margin" Value="0,0,3,3" TargetName="SubMenu"/>
855 <Setter Property="SnapsToDevicePixels" Value="true" TargetName="SubMenu"/>
856 <Setter Property="BitmapEffect" Value="{DynamicResource PopupDropShadow}" TargetName="SubMenuBorder"/>
857 </Trigger>
858
859 <!-- Using the system colors for the Menu Highlight and IsEnabled-->
860 <Trigger Property="IsHighlighted" Value="true">
861 <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" TargetName="Border"/>
862 <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
863 </Trigger>
864 <Trigger Property="IsEnabled" Value="false">
865 <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
866 </Trigger>
867 </ControlTemplate.Triggers>
868 </ControlTemplate>
869 </Setter.Value>
870 </Setter>
871 </Style>
872
873 <!-- Simple Separator - This template is used for a Separator in a menu -->
874 <Style x:Key="SimpleSeparator" TargetType="{x:Type Separator}">
875 <Setter Property="Height" Value="1"/>
876 <Setter Property="Margin" Value="0,2,0,2"/>
877 <Setter Property="Focusable" Value="false"/>
878 <Setter Property="Template">
879 <Setter.Value>
880 <ControlTemplate TargetType="{x:Type Separator}">
881 <Border BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1"/>
882 </ControlTemplate>
883 </Setter.Value>
884 </Setter>
885 </Style>
886
887 <!-- Simple TabControl
888 This template uses Simple TabItem for each Tab. The TabItems are placed in the TabPanel
889 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-->
890
891 <Style x:Key="SimpleTabControl" TargetType="{x:Type TabControl}">
892 <Setter Property="Template">
893 <Setter.Value>
894 <ControlTemplate TargetType="{x:Type TabControl}">
895 <Grid KeyboardNavigation.TabNavigation="Local">
896 <Grid.RowDefinitions>
897 <RowDefinition Height="Auto"/>
898 <RowDefinition Height="*"/>
899 </Grid.RowDefinitions>
900
901 <!-- TabPanel is a layout container which allows the TabItems to wrap and re-order when selected
902 The implementation knows to use this control because it is marked IsItemsHost = True -->
903 <TabPanel Grid.Row="0" Margin="0,0,4,-1" x:Name="HeaderPanel" Background="Transparent" IsItemsHost="True" Panel.ZIndex="1" KeyboardNavigation.TabIndex="1"/>
904
905 <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">
906
907 <!-- The implementation switches the content. This control must be named PART_SelectedContentHost -->
908 <ContentPresenter Margin="4" x:Name="PART_SelectedContentHost" ContentSource="SelectedContent"/>
909
910 </Border>
911 </Grid>
912
913 <ControlTemplate.Triggers>
914 <Trigger Property="IsEnabled" Value="False">
915 <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
916 <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
917 </Trigger>
918 </ControlTemplate.Triggers>
919
920 </ControlTemplate>
921 </Setter.Value>
922 </Setter>
923 </Style>
924
925 <!--Simple TabItem -->
926 <Style x:Key="SimpleTabItem" d:IsControlPart="True" TargetType="{x:Type TabItem}">
927 <Setter Property="Template">
928 <Setter.Value>
929 <ControlTemplate TargetType="{x:Type TabItem}">
930 <Grid>
931 <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">
932 <ContentPresenter HorizontalAlignment="Center" Margin="12,2,12,2" x:Name="ContentSite" VerticalAlignment="Center" RecognizesAccessKey="True" ContentSource="Header"/>
933 </Border>
934 </Grid>
935 <ControlTemplate.Triggers>
936 <Trigger Property="IsSelected" Value="True">
937 <Setter Property="Panel.ZIndex" Value="100"/>
938 <Setter Property="Background" Value="{DynamicResource WindowBackgroundBrush}" TargetName="Border"/>
939 <Setter Property="BorderThickness" Value="1,1,1,0" TargetName="Border"/>
940 </Trigger>
941 <Trigger Property="IsEnabled" Value="False">
942 <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
943 <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
944 <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
945 </Trigger>
946 </ControlTemplate.Triggers>
947 </ControlTemplate>
948 </Setter.Value>
949 </Setter>
950 </Style>
951
952 <!--Simple Simple SliderThumb - The Thumb is the draggable part of a Slider-->
953 <Style x:Key="SimpleSliderThumb" d:IsControlPart="True" TargetType="{x:Type Thumb}">
954 <Setter Property="SnapsToDevicePixels" Value="true"/>
955 <Setter Property="Height" Value="14"/>
956 <Setter Property="Width" Value="14"/>
957 <Setter Property="Template">
958 <Setter.Value>
959 <ControlTemplate TargetType="{x:Type Thumb}">
960 <Grid>
961 <Ellipse x:Name="Ellipse" Fill="{DynamicResource NormalBrush}" Stroke="{DynamicResource NormalBorderBrush}" StrokeThickness="1"/>
962 </Grid>
963 <ControlTemplate.Triggers>
964 <Trigger Property="IsMouseOver" Value="True">
965 <Setter Property="Fill" Value="{DynamicResource MouseOverBrush}" TargetName="Ellipse"/>
966 </Trigger>
967 <Trigger Property="IsEnabled" Value="false">
968 <Setter Property="Fill" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Ellipse"/>
969 </Trigger>
970 </ControlTemplate.Triggers>
971 </ControlTemplate>
972 </Setter.Value>
973 </Setter>
974 </Style>
975
976 <!--Simple Simple Slider
977 Similiar to ScrollBar this template uses Track to layout the draggable Thumb which has an up and down repeat button
978 It uses Simple SliderThumb and SimpleScrollRepeatButtonStyle for the page up and down repeat buttons -->
979 <Style x:Key="SimpleSlider" TargetType="{x:Type Slider}">
980 <Setter Property="Background" Value="{DynamicResource LightBrush}"/>
981 <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
982 <Setter Property="Template">
983 <Setter.Value>
984 <ControlTemplate TargetType="{x:Type Slider}">
985 <Grid x:Name="GridRoot">
986 <Grid.RowDefinitions>
987 <RowDefinition Height="Auto"/>
988 <RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}"/>
989 <RowDefinition Height="Auto"/>
990 </Grid.RowDefinitions>
991
992 <!-- TickBar shows the ticks for Slider -->
993 <TickBar Visibility="Collapsed" x:Name="TopTick" Height="4" SnapsToDevicePixels="True" Placement="Top" Fill="{DynamicResource GlyphBrush}"/>
994 <Border Grid.Row="1" Margin="0" x:Name="Border" Height="4" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/>
995
996 <!-- The Track lays out the repeat buttons and thumb -->
997 <Track Grid.Row="1" x:Name="PART_Track">
998 <Track.Thumb>
999 <Thumb Style="{DynamicResource SimpleSliderThumb}"/>
1000 </Track.Thumb>
1001 <Track.IncreaseRepeatButton>
1002 <RepeatButton Style="{DynamicResource SimpleScrollRepeatButtonStyle}" Command="Slider.IncreaseLarge"/>
1003 </Track.IncreaseRepeatButton>
1004 <Track.DecreaseRepeatButton>
1005 <RepeatButton Style="{DynamicResource SimpleScrollRepeatButtonStyle}" Command="Slider.DecreaseLarge"/>
1006 </Track.DecreaseRepeatButton>
1007 </Track>
1008
1009 <TickBar Visibility="Collapsed" Grid.Row="2" x:Name="BottomTick" Height="4" SnapsToDevicePixels="True" Placement="Bottom" Fill="{TemplateBinding Foreground}"/>
1010 </Grid>
1011 <ControlTemplate.Triggers>
1012 <Trigger Property="TickPlacement" Value="TopLeft">
1013 <Setter Property="Visibility" Value="Visible" TargetName="TopTick"/>
1014 </Trigger>
1015 <Trigger Property="TickPlacement" Value="BottomRight">
1016 <Setter Property="Visibility" Value="Visible" TargetName="BottomTick"/>
1017 </Trigger>
1018 <Trigger Property="TickPlacement" Value="Both">
1019 <Setter Property="Visibility" Value="Visible" TargetName="TopTick"/>
1020 <Setter Property="Visibility" Value="Visible" TargetName="BottomTick"/>
1021 </Trigger>
1022 <Trigger Property="IsEnabled" Value="false">
1023 <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
1024 <Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
1025 </Trigger>
1026
1027 <!-- Use a rotation to create a Vertical Slider form the default Horizontal -->
1028 <Trigger Property="Orientation" Value="Vertical">
1029 <Setter Property="LayoutTransform" TargetName="GridRoot">
1030 <Setter.Value>
1031 <RotateTransform Angle="-90"/>
1032 </Setter.Value>
1033 </Setter>
1034 <!-- Track rotates itself based on orientation so need to force it back -->
1035 <Setter TargetName="PART_Track" Property="Orientation" Value="Horizontal"/>
1036 </Trigger>
1037
1038 </ControlTemplate.Triggers>
1039 </ControlTemplate>
1040 </Setter.Value>
1041 </Setter>
1042 </Style>
1043
1044 <!--Simple Tree View - This lays out TreeViewItems within a ScrollViewer -->
1045 <Style x:Key="SimpleTreeView" TargetType="{x:Type TreeView}">
1046 <Setter Property="Template">
1047 <Setter.Value>
1048 <ControlTemplate TargetType="{x:Type TreeView}">
1049 <Grid>
1050 <Border x:Name="Border" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1" CornerRadius="1">
1051 <ScrollViewer Style="{DynamicResource SimpleScrollViewer}" Focusable="False" Background="{TemplateBinding Background}" Padding="4" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="False">
1052 <ItemsPresenter/>
1053 </ScrollViewer>
1054 </Border>
1055 </Grid>
1056 </ControlTemplate>
1057 </Setter.Value>
1058 </Setter>
1059 </Style>
1060
1061 <!--Simple TreeViewItem ToggleButton - + and - button to expand and collapse a TreeViewItem -->
1062 <Style x:Key="SimpleTreeViewItemToggleButton" d:IsControlPart="True" TargetType="{x:Type ToggleButton}">
1063 <Setter Property="Focusable" Value="False"/>
1064 <Setter Property="Template">
1065 <Setter.Value>
1066 <ControlTemplate TargetType="{x:Type ToggleButton}">
1067 <Grid Width="15" Height="13" Background="Transparent">
1068 <Path Visibility="Collapsed" HorizontalAlignment="Left" Margin="1,1,1,1" x:Name="IsExpandedPath" VerticalAlignment="Center" Fill="{DynamicResource GlyphBrush}" Data="M 0 4 L 8 4 L 4 8 Z"/>
1069 <Path HorizontalAlignment="Left" Margin="1,1,1,1" x:Name="ExpandPath" VerticalAlignment="Center" Fill="{DynamicResource GlyphBrush}" Data="M 4 0 L 8 4 L 4 8 Z"/>
1070 </Grid>
1071 <ControlTemplate.Triggers>
1072 <Trigger Property="IsChecked" Value="True">
1073 <Setter Property="Visibility" Value="Visible" TargetName="IsExpandedPath"/>
1074 <Setter Property="Visibility" Value="Collapsed" TargetName="ExpandPath"/>
1075 </Trigger>
1076 </ControlTemplate.Triggers>
1077 </ControlTemplate>
1078 </Setter.Value>
1079 </Setter>
1080 </Style>
1081
1082 <!--Simple TreeViewItem - The TreeViewItem template has a header which shows the Item and a Body which is an ItemsHost control which expands to show child items-->
1083 <Style x:Key="SimpleTreeViewItem" d:IsControlPart="True" TargetType="{x:Type TreeViewItem}">
1084 <Setter Property="Background" Value="Transparent"/>
1085 <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
1086 <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
1087 <Setter Property="Padding" Value="1,0,0,0"/>
1088 <Setter Property="Template">
1089 <Setter.Value>
1090 <ControlTemplate TargetType="{x:Type TreeViewItem}">
1091 <Grid>
1092 <Grid.ColumnDefinitions>
1093 <ColumnDefinition MinWidth="19" Width="Auto"/>
1094 <ColumnDefinition Width="Auto"/>
1095 <ColumnDefinition Width="*"/>
1096 </Grid.ColumnDefinitions>
1097 <Grid.RowDefinitions>
1098 <RowDefinition Height="Auto"/>
1099 <RowDefinition/>
1100 </Grid.RowDefinitions>
1101 <ToggleButton x:Name="Expander" Style="{DynamicResource SimpleTreeViewItemToggleButton}" IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
1102 <Border Grid.Column="1" x:Name="Selection_Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
1103 <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" x:Name="PART_Header" ContentSource="Header"/>
1104 </Border>
1105 <ItemsPresenter Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" x:Name="ItemsHost"/>
1106 </Grid>
1107 <ControlTemplate.Triggers>
1108 <Trigger Property="IsExpanded" Value="false">
1109 <Setter Property="Visibility" Value="Collapsed" TargetName="ItemsHost"/>
1110 </Trigger>
1111 <Trigger Property="HasItems" Value="false">
1112 <Setter Property="Visibility" Value="Hidden" TargetName="Expander"/>
1113 </Trigger>
1114 <Trigger Property="IsSelected" Value="true">
1115 <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" TargetName="Selection_Border"/>
1116 <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
1117 </Trigger>
1118 <MultiTrigger>
1119 <MultiTrigger.Conditions>
1120 <Condition Property="IsSelected" Value="true"/>
1121 <Condition Property="IsSelectionActive" Value="false"/>
1122 </MultiTrigger.Conditions>
1123 <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" TargetName="Selection_Border"/>
1124 <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
1125 </MultiTrigger>
1126 <Trigger Property="IsEnabled" Value="false">
1127 <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
1128 </Trigger>
1129 </ControlTemplate.Triggers>
1130 </ControlTemplate>
1131 </Setter.Value>
1132 </Setter>
1133 </Style>
1134</ResourceDictionary>