-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Expand file tree
/
Copy pathMaterialDesignTheme.ToolBar.xaml
More file actions
415 lines (406 loc) · 22.6 KB
/
MaterialDesignTheme.ToolBar.xaml
File metadata and controls
415 lines (406 loc) · 22.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters"
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.CheckBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ComboBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Menu.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RadioButton.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToggleButton.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Font.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ListBox.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="MaterialDesignToolBarVerticalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="{Binding Background, RelativeSource={RelativeSource AncestorType=ToolBar}}" />
<Setter Property="MinHeight" Value="0" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="Bd"
Background="{TemplateBinding Background}"
CornerRadius="0,0,3,3"
SnapsToDevicePixels="true">
<Viewbox Width="16" Height="16">
<Canvas Width="24" Height="24">
<Path Data="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z" Fill="{TemplateBinding Foreground}" />
</Canvas>
</Viewbox>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<!-- Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/ -->
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<!-- Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/ -->
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value=".56" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="MaterialDesignToolBarHorizontalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="{Binding Background, RelativeSource={RelativeSource AncestorType=ToolBar}}" />
<Setter Property="MinHeight" Value="0" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="Bd"
Background="{TemplateBinding Background}"
CornerRadius="0,3,3,0"
SnapsToDevicePixels="true">
<Viewbox Width="16"
Height="16"
Margin="8,0,8,0">
<Canvas Width="24" Height="24">
<Path Data="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z" Fill="{TemplateBinding Foreground}" />
</Canvas>
</Viewbox>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<!-- Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/ -->
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<!-- Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/ -->
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value=".56" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="MaterialDesignToolBarThumbStyle" TargetType="{x:Type Thumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border Padding="{TemplateBinding Padding}"
Background="Transparent"
SnapsToDevicePixels="True">
<Rectangle>
<Rectangle.Fill>
<DrawingBrush TileMode="Tile"
Viewbox="0,0,4,4"
ViewboxUnits="Absolute"
Viewport="0,0,4,4"
ViewportUnits="Absolute">
<DrawingBrush.Drawing>
<GeometryDrawing Brush="{DynamicResource MaterialDesign.Brush.ToolBar.Thumb.Foreground}" Geometry="M 0 0 L 0 2 L 2 2 L 2 0 z" />
</DrawingBrush.Drawing>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Cursor" Value="SizeAll" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="MaterialDesignToolBarMainPanelBorderStyle" TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="3,3,3,3" />
<Setter Property="Margin" Value="0,0,11,0" />
</Style>
<Style x:Key="MaterialDesignToolBar" TargetType="{x:Type ToolBar}">
<Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.ToolBar.Background}" />
<Setter Property="ClipToBounds" Value="True" />
<Setter Property="Foreground" Value="{DynamicResource MaterialDesign.Brush.Foreground}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToolBar}">
<ControlTemplate.Resources>
<Style TargetType="{x:Type wpf:PackIcon}">
<Setter Property="FrameworkElement.Height" Value="22" />
<Setter Property="FrameworkElement.Width" Value="22" />
</Style>
<Style TargetType="ListBox" BasedOn="{StaticResource MaterialDesignToolToggleFlatListBox}">
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MaterialDesignToolToggleListBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="MinWidth" Value="54" />
<Setter Property="Padding" Value="16" />
<Setter Property="TextBlock.FontSize" Value="18" />
<Setter Property="TextBlock.FontWeight" Value="DemiBold" />
</Style>
</Setter.Value>
</Setter>
</Style>
</ControlTemplate.Resources>
<DockPanel x:Name="Grid"
Margin="3,1,1,1"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="true">
<Grid x:Name="OverflowGrid"
HorizontalAlignment="Right"
DockPanel.Dock="Right">
<ToggleButton x:Name="OverflowButton"
ClickMode="Press"
FocusVisualStyle="{x:Null}"
Foreground="{TemplateBinding Foreground}"
IsChecked="{Binding IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource MaterialDesignToolBarHorizontalOverflowButtonStyle}">
<ToggleButton.Visibility>
<MultiBinding Converter="{x:Static converters:ToolBarOverflowButtonVisibilityConverter.Instance}">
<Binding Path="OverflowMode" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="HasOverflowItems" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</ToggleButton.Visibility>
</ToggleButton>
<Popup x:Name="OverflowPopup"
Margin="1"
AllowsTransparency="true"
Focusable="false"
IsOpen="{Binding IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom"
PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"
StaysOpen="false"
CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}">
<Border x:Name="ToolBarSubMenuBorder"
Margin="1"
Background="{TemplateBinding Background}"
BorderBrush="{DynamicResource MaterialDesign.Brush.ToolBar.Overflow.Border}"
BorderThickness="1"
CornerRadius="2"
Effect="{StaticResource MaterialDesignShadowDepth2}"
RenderOptions.ClearTypeHint="Enabled"
TextBlock.FontWeight="ExtraBold">
<Border Background="Transparent">
<ToolBarOverflowPanel x:Name="PART_ToolBarOverflowPanel"
Margin="2"
FocusVisualStyle="{x:Null}"
Focusable="true"
KeyboardNavigation.DirectionalNavigation="Cycle"
KeyboardNavigation.TabNavigation="Cycle"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
WrapWidth="200" />
</Border>
</Border>
</Popup>
</Grid>
<Border x:Name="MainPanelBorder"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Style="{StaticResource MaterialDesignToolBarMainPanelBorderStyle}">
<DockPanel KeyboardNavigation.TabIndex="1" KeyboardNavigation.TabNavigation="Local">
<Thumb x:Name="ToolBarThumb"
Width="10"
Margin="-3,-1,4,0"
Padding="6,5,1,3"
Style="{StaticResource MaterialDesignToolBarThumbStyle}" />
<ContentPresenter x:Name="ToolBarHeader"
Margin="4,0,4,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Header"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<ToolBarPanel x:Name="PART_ToolBarPanel"
Margin="0,0,2,0"
IsItemsHost="true"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</DockPanel>
</Border>
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsOverflowOpen" Value="true">
<Setter TargetName="ToolBarThumb" Property="IsEnabled" Value="false" />
</Trigger>
<Trigger Property="Header" Value="{x:Null}">
<Setter TargetName="ToolBarHeader" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="ToolBarTray.IsLocked" Value="true">
<Setter TargetName="ToolBarThumb" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger SourceName="OverflowPopup" Property="HasDropShadow" Value="true">
<Setter TargetName="ToolBarSubMenuBorder" Property="Margin" Value="5,5,5,5" />
</Trigger>
<Trigger Property="Orientation" Value="Vertical">
<Setter TargetName="Grid" Property="Margin" Value="1,3,1,1" />
<Setter TargetName="MainPanelBorder" Property="Margin" Value="0,0,0,11" />
<Setter TargetName="OverflowButton" Property="Style" Value="{StaticResource MaterialDesignToolBarVerticalOverflowButtonStyle}" />
<Setter TargetName="OverflowGrid" Property="DockPanel.Dock" Value="Bottom" />
<Setter TargetName="OverflowGrid" Property="HorizontalAlignment" Value="Stretch" />
<Setter TargetName="OverflowGrid" Property="VerticalAlignment" Value="Bottom" />
<Setter TargetName="OverflowPopup" Property="Placement" Value="Right" />
<Setter TargetName="PART_ToolBarPanel" Property="Margin" Value="1,0,2,2" />
<Setter TargetName="ToolBarHeader" Property="DockPanel.Dock" Value="Top" />
<Setter TargetName="ToolBarHeader" Property="Margin" Value="0,0,0,4" />
<Setter TargetName="ToolBarThumb" Property="DockPanel.Dock" Value="Top" />
<Setter TargetName="ToolBarThumb" Property="Height" Value="10" />
<Setter TargetName="ToolBarThumb" Property="Margin" Value="-1,-3,0,0" />
<Setter TargetName="ToolBarThumb" Property="Padding" Value="5,6,6,1" />
<Setter TargetName="ToolBarThumb" Property="Width" Value="Auto" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value=".56" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Static ToolBar.CheckBoxStyleKey}"
TargetType="{x:Type CheckBox}"
BasedOn="{StaticResource MaterialDesignCheckBox}">
<Setter Property="Margin" Value="8,0,8,0" />
</Style>
<Style x:Key="{x:Static ToolBar.ComboBoxStyleKey}"
TargetType="{x:Type ComboBox}"
BasedOn="{StaticResource MaterialDesignComboBox}">
<Setter Property="Margin" Value="8,0,8,0" />
</Style>
<Style x:Key="{x:Static ToolBar.MenuStyleKey}"
TargetType="{x:Type Menu}"
BasedOn="{StaticResource MaterialDesignMenu}">
<Setter Property="Margin" Value="8,0,8,0" />
</Style>
<Style x:Key="{x:Static ToolBar.RadioButtonStyleKey}"
TargetType="{x:Type RadioButton}"
BasedOn="{StaticResource MaterialDesignRadioButton}">
<Setter Property="Margin" Value="8,0,8,0" />
</Style>
<Style x:Key="{x:Static ToolBar.SeparatorStyleKey}" TargetType="Separator">
<Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.ToolBar.Separator}" />
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.ToolBar.Separator}" />
<Setter Property="Margin" Value="6,11,6,11" />
<Setter Property="MinHeight" Value="1" />
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Separator}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Static ToolBar.TextBoxStyleKey}"
TargetType="{x:Type TextBox}"
BasedOn="{StaticResource MaterialDesignTextBox}">
<Setter Property="Margin" Value="8,0,8,0" />
</Style>
<Style x:Key="MaterialDesignToolBarToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="{DynamicResource MaterialDesign.Brush.Foreground}" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Margin" Value="0" />
<Setter Property="MinWidth" Value="54" />
<Setter Property="Padding" Value="16" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Margin="{TemplateBinding Margin}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
ClipToBounds="{TemplateBinding ClipToBounds}"
CornerRadius="2">
<Grid>
<Border x:Name="MouseOverBorder"
Background="{TemplateBinding Foreground, Converter={x:Static converters:BrushRoundConverter.Instance}}"
Opacity="0" />
<Border x:Name="SelectedBackgroundBorder"
Background="{DynamicResource MaterialDesign.Brush.ListBoxItem.Selected}"
Opacity="0" />
<wpf:Ripple x:Name="Ripple"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Feedback="{TemplateBinding Foreground, Converter={x:Static converters:BrushRoundConverter.Instance}}"
Focusable="False"
Opacity=".56"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="SelectedBackgroundBorder" Property="Opacity" Value="1" />
<Setter TargetName="Ripple" Property="Opacity" Value=".92" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="MouseOverBorder" Property="Opacity" Value=".03" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter TargetName="MouseOverBorder" Property="Opacity" Value=".03" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value=".56" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="TextBlock.FontWeight" Value="DemiBold" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
<Style x:Key="{x:Static ToolBar.ToggleButtonStyleKey}"
TargetType="{x:Type ToggleButton}"
BasedOn="{StaticResource MaterialDesignToolBarToggleButton}" />
<Style x:Key="{x:Static ToolBar.ButtonStyleKey}" TargetType="Button">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Foreground" Value="{DynamicResource MaterialDesign.Brush.Foreground}" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="16" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="border"
Background="Transparent"
CornerRadius="2">
<wpf:Ripple Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Feedback="{TemplateBinding Foreground}"
Focusable="False"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value=".56" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="border" Property="Background" Value="{DynamicResource MaterialDesign.Brush.Button.FlatClick}" />
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.Button.FlatClick}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="TextBlock.FontWeight" Value="DemiBold" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="wpf:RippleAssist.Feedback" Value="{DynamicResource MaterialDesign.Brush.Button.Ripple}" />
</Style>
</ResourceDictionary>