Skip to content

Commit 54bc723

Browse files
committed
more toolbar tidy up
1 parent b0b59f7 commit 54bc723

File tree

6 files changed

+70
-46
lines changed

6 files changed

+70
-46
lines changed

MaterialDesignColors.WpfExample/ProvingGround.xaml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,10 @@
5050
<SolidColorBrush x:Key="SecondaryAccentForegroundBrush" Color="{StaticResource Accent700Foreground}"/>
5151
</ResourceDictionary>
5252
</ResourceDictionary.MergedDictionaries>
53-
<Style x:Key="GridSplitterPreviewStyle">
54-
<Setter Property="Control.Template">
55-
<Setter.Value>
56-
<ControlTemplate>
57-
<Rectangle Fill="#80000000"/>
58-
</ControlTemplate>
59-
</Setter.Value>
60-
</Setter>
61-
</Style>
62-
<Style x:Key="MaterialDesignGridSplitter" TargetType="{x:Type GridSplitter}">
63-
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
64-
<Setter Property="PreviewStyle" Value="{StaticResource GridSplitterPreviewStyle}"/>
65-
<Setter Property="Template">
66-
<Setter.Value>
67-
<ControlTemplate TargetType="{x:Type GridSplitter}">
68-
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
69-
</ControlTemplate>
70-
</Setter.Value>
71-
</Setter>
72-
</Style>
53+
54+
55+
56+
7357

7458

7559

@@ -82,7 +66,7 @@
8266
</UserControl.Resources>
8367

8468
<Grid>
85-
<GridSplitter Style="{DynamicResource MaterialDesignGridSplitter}" />
69+
<ToolBarTray Style="{DynamicResource MaterialDesignToolBarTray}" />
8670
</Grid>
8771

8872
</UserControl>

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
<SubType>Designer</SubType>
9797
<Generator>MSBuild:Compile</Generator>
9898
</Page>
99+
<Page Include="Themes\MaterialDesignTheme.Label.xaml">
100+
<SubType>Designer</SubType>
101+
<Generator>MSBuild:Compile</Generator>
102+
</Page>
99103
<Page Include="Themes\MaterialDesignTheme.MahApps.Dialogs.xaml">
100104
<SubType>Designer</SubType>
101105
<Generator>MSBuild:Compile</Generator>
@@ -172,6 +176,10 @@
172176
<SubType>Designer</SubType>
173177
<Generator>MSBuild:Compile</Generator>
174178
</Page>
179+
<Page Include="Themes\MaterialDesignTheme.ToolBarTray.xaml">
180+
<SubType>Designer</SubType>
181+
<Generator>MSBuild:Compile</Generator>
182+
</Page>
175183
<Page Include="Themes\MaterialDesignTheme.ToolTip.xaml">
176184
<SubType>Designer</SubType>
177185
<Generator>MSBuild:Compile</Generator>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Defaults.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.DataGrid.xaml" />
1313
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.DatePicker.xaml" />
1414
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.GridSplitter.xaml" />
15+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.Label.xaml" />
1516
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.listbox.xaml" />
1617
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Menu.xaml" />
1718
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PasswordBox.xaml" />
@@ -23,6 +24,7 @@
2324
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.textbox.xaml" />
2425
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.togglebutton.xaml" />
2526
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToolBar.xaml" />
27+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToolBarTray.xaml" />
2628
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToolTip.xaml" />
2729
</ResourceDictionary.MergedDictionaries>
2830
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignRaisedButton}" />
@@ -36,6 +38,7 @@
3638
<Style TargetType="{x:Type DataGridRowHeader}" BasedOn="{StaticResource MaterialDesignDataGridRowHeader}" />
3739
<Style TargetType="{x:Type DatePicker}" BasedOn="{StaticResource MaterialDesignDatePicker}" />
3840
<Style TargetType="{x:Type GridSplitter}" BasedOn="{StaticResource MaterialDesignGridSplitter}" />
41+
<Style TargetType="{x:Type Label}" BasedOn="{StaticResource MaterialDesignLabel}" />
3942
<Style TargetType="{x:Type ListBox}" BasedOn="{StaticResource MaterialDesignListBox}" />
4043
<Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource MaterialDesignPasswordBox}" />
4144
<Style TargetType="{x:Type ProgressBar}" BasedOn="{StaticResource MaterialDesignLinearProgressBar}" />
@@ -46,6 +49,7 @@
4649
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignTextBox}" />
4750
<Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignSwitchToggleButton}" />
4851
<Style TargetType="{x:Type ToolBar}" BasedOn="{StaticResource MaterialDesignToolBar}" />
52+
<Style TargetType="{x:Type ToolBarTray}" BasedOn="{StaticResource MaterialDesignToolBarTray}" />
4953
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource MaterialDesignToolTip}" />
5054
<Style TargetType="{x:Type Menu}" BasedOn="{StaticResource MaterialDesignMenu}" />
5155
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MaterialDesignMenuItem}" />
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
<Style x:Key="MaterialDesignLabel" TargetType="{x:Type Label}">
4+
<Setter Property="Foreground" Value="{DynamicResource MaterialDesignBody}"/>
5+
<Setter Property="Background" Value="Transparent"/>
6+
<Setter Property="Padding" Value="5"/>
7+
<Setter Property="HorizontalContentAlignment" Value="Left"/>
8+
<Setter Property="VerticalContentAlignment" Value="Top"/>
9+
<Setter Property="Template">
10+
<Setter.Value>
11+
<ControlTemplate TargetType="{x:Type Label}">
12+
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
13+
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
14+
</Border>
15+
<ControlTemplate.Triggers>
16+
<Trigger Property="IsEnabled" Value="false">
17+
<Setter Property="Opacity" Value=".56" />
18+
</Trigger>
19+
</ControlTemplate.Triggers>
20+
</ControlTemplate>
21+
</Setter.Value>
22+
</Setter>
23+
</Style>
24+
</ResourceDictionary>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToolBar.xaml

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.togglebutton.xaml" />
1313
</ResourceDictionary.MergedDictionaries>
1414

15-
<Style x:Key="ToolBarVerticalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
15+
<Style x:Key="MaterialDesignToolBarVerticalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
1616
<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}"/>
1717
<Setter Property="MinHeight" Value="0"/>
1818
<Setter Property="MinWidth" Value="0"/>
@@ -46,7 +46,8 @@
4646
</DataTrigger>
4747
</Style.Triggers>
4848
</Style>
49-
<Style x:Key="ToolBarHorizontalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
49+
50+
<Style x:Key="MaterialDesignToolBarHorizontalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
5051
<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}"/>
5152
<Setter Property="MinHeight" Value="0"/>
5253
<Setter Property="MinWidth" Value="0"/>
@@ -80,7 +81,8 @@
8081
</DataTrigger>
8182
</Style.Triggers>
8283
</Style>
83-
<Style x:Key="ToolBarThumbStyle" TargetType="{x:Type Thumb}">
84+
85+
<Style x:Key="MaterialDesignToolBarThumbStyle" TargetType="{x:Type Thumb}">
8486
<Setter Property="Template">
8587
<Setter.Value>
8688
<ControlTemplate TargetType="{x:Type Thumb}">
@@ -90,7 +92,6 @@
9092
<DrawingBrush TileMode="Tile" Viewbox="0,0,4,4" Viewport="0,0,4,4" ViewportUnits="Absolute" ViewboxUnits="Absolute">
9193
<DrawingBrush.Drawing>
9294
<DrawingGroup>
93-
<GeometryDrawing Brush="White" Geometry="M 1 1 L 1 3 L 3 3 L 3 1 z"/>
9495
<GeometryDrawing Brush="{DynamicResource MaterialDesignDivider}" Geometry="M 0 0 L 0 2 L 2 2 L 2 0 z"/>
9596
</DrawingGroup>
9697
</DrawingBrush.Drawing>
@@ -107,27 +108,26 @@
107108
</Setter.Value>
108109
</Setter>
109110
</Style>
110-
<Style x:Key="ToolBarMainPanelBorderStyle" TargetType="{x:Type Border}">
111+
112+
<Style x:Key="MaterialDesignToolBarMainPanelBorderStyle" TargetType="{x:Type Border}">
111113
<Setter Property="Margin" Value="0,0,11,0"/>
112114
<Setter Property="CornerRadius" Value="3,3,3,3"/>
113-
<Style.Triggers>
114-
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
115-
<Setter Property="CornerRadius" Value="0,0,0,0"/>
116-
</DataTrigger>
117-
</Style.Triggers>
118115
</Style>
116+
119117
<Style x:Key="MaterialDesignToolBar" TargetType="{x:Type ToolBar}">
120118
<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}"/>
121119
<Setter Property="FontFamily" Value="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"/>
122120
<Setter Property="Foreground" Value="{DynamicResource MaterialDesignBody}"/>
121+
<Setter Property="ClipToBounds" Value="True"/>
123122
<Setter Property="Template">
124123
<Setter.Value>
125124
<ControlTemplate TargetType="{x:Type ToolBar}">
126125
<DockPanel x:Name="Grid" Margin="3,1,1,1" SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
127126
<Grid DockPanel.Dock="Right" x:Name="OverflowGrid" HorizontalAlignment="Right">
128-
<ToggleButton x:Name="OverflowButton" ClickMode="Press" FocusVisualStyle="{x:Null}" IsChecked="{Binding IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" IsEnabled="{TemplateBinding HasOverflowItems}" Style="{StaticResource ToolBarHorizontalOverflowButtonStyle}"
127+
<ToggleButton x:Name="OverflowButton" ClickMode="Press" FocusVisualStyle="{x:Null}" IsChecked="{Binding IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" IsEnabled="{TemplateBinding HasOverflowItems}" Style="{StaticResource MaterialDesignToolBarHorizontalOverflowButtonStyle}"
128+
Foreground="{TemplateBinding Foreground}"
129129
/>
130-
<Popup x:Name="OverflowPopup" AllowsTransparency="true" Focusable="false" IsOpen="{Binding IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom" StaysOpen="false" Margin="1">
130+
<Popup x:Name="OverflowPopup" AllowsTransparency="true" Focusable="false" IsOpen="{Binding IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom" StaysOpen="false" Margin="1">
131131
<Border x:Name="ToolBarSubMenuBorder" BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="1" Background="{DynamicResource MaterialDesignPaper}"
132132
TextBlock.FontWeight="ExtraBold"
133133
CornerRadius="2" Margin="1"
@@ -138,9 +138,9 @@
138138
</Border>
139139
</Popup>
140140
</Grid>
141-
<Border x:Name="MainPanelBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" Style="{StaticResource ToolBarMainPanelBorderStyle}">
141+
<Border x:Name="MainPanelBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" Style="{StaticResource MaterialDesignToolBarMainPanelBorderStyle}">
142142
<DockPanel KeyboardNavigation.TabIndex="1" KeyboardNavigation.TabNavigation="Local">
143-
<Thumb x:Name="ToolBarThumb" Margin="-3,-1,0,0" Padding="6,5,1,6" Style="{StaticResource ToolBarThumbStyle}" Width="10"/>
143+
<Thumb x:Name="ToolBarThumb" Margin="-3,-1,0,0" Padding="6,5,1,6" Style="{StaticResource MaterialDesignToolBarThumbStyle}" Width="10"/>
144144
<ContentPresenter x:Name="ToolBarHeader" ContentSource="Header" HorizontalAlignment="Center" Margin="4,0,4,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
145145
<ToolBarPanel x:Name="PART_ToolBarPanel" IsItemsHost="true" Margin="0,1,2,2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
146146
</DockPanel>
@@ -161,7 +161,7 @@
161161
</Trigger>
162162
<Trigger Property="Orientation" Value="Vertical">
163163
<Setter Property="Margin" TargetName="Grid" Value="1,3,1,1"/>
164-
<Setter Property="Style" TargetName="OverflowButton" Value="{StaticResource ToolBarVerticalOverflowButtonStyle}"/>
164+
<Setter Property="Style" TargetName="OverflowButton" Value="{StaticResource MaterialDesignToolBarVerticalOverflowButtonStyle}"/>
165165
<Setter Property="Height" TargetName="ToolBarThumb" Value="10"/>
166166
<Setter Property="Width" TargetName="ToolBarThumb" Value="Auto"/>
167167
<Setter Property="Margin" TargetName="ToolBarThumb" Value="-1,-3,0,0"/>
@@ -183,11 +183,6 @@
183183
</ControlTemplate>
184184
</Setter.Value>
185185
</Setter>
186-
<Style.Triggers>
187-
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
188-
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
189-
</DataTrigger>
190-
</Style.Triggers>
191186
</Style>
192187

193188
<Style x:Key="{x:Static ToolBar.CheckBoxStyleKey}" TargetType="{x:Type CheckBox}" BasedOn="{StaticResource MaterialDesignCheckBox}">
@@ -227,14 +222,17 @@
227222
<Setter Property="HorizontalContentAlignment" Value="Center"/>
228223
<Setter Property="VerticalContentAlignment" Value="Center"/>
229224
<Setter Property="TextBlock.FontWeight" Value="DemiBold"/>
225+
<Setter Property="Foreground" Value="{DynamicResource MaterialDesignBody}"/>
230226
<Setter Property="Template">
231227
<Setter.Value>
232228
<ControlTemplate TargetType="{x:Type Button}">
233-
<wpf:VisualFeedbackContentControl Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
234-
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
235-
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
236-
Padding="{TemplateBinding Padding}"
237-
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
229+
<wpf:VisualFeedbackContentControl Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
230+
Foreground="{TemplateBinding Foreground}"
231+
ClipToBounds="False"
232+
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
233+
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
234+
Padding="{TemplateBinding Padding}"
235+
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
238236
<ControlTemplate.Triggers>
239237
<Trigger Property="IsEnabled" Value="false">
240238
<Setter Property="Opacity" Value=".56"/>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
<Style x:Key="MaterialDesignToolBarTray" TargetType="{x:Type ToolBarTray}">
4+
<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}"/>
5+
</Style>
6+
</ResourceDictionary>

0 commit comments

Comments
 (0)