Skip to content

Commit ddf9eb9

Browse files
committed
toolbar stuff
1 parent ed06f4f commit ddf9eb9

File tree

5 files changed

+271
-214
lines changed

5 files changed

+271
-214
lines changed

MaterialDesignColors.WpfExample/App.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Application x:Class="MaterialDesignColors.WpfExample.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
StartupUri="MainWindow.xaml">
4+
StartupUri="ProvingGround.xaml">
55
<Application.Resources>
66
<ResourceDictionary>
77
<ResourceDictionary.MergedDictionaries>

MaterialDesignColors.WpfExample/ProvingGround.xaml

Lines changed: 16 additions & 211 deletions
Original file line numberDiff line numberDiff line change
@@ -52,217 +52,7 @@
5252

5353

5454

55-
<SolidColorBrush x:Key="ToolBarHorizontalBackground" Color="#FFEEF5FD"/>
56-
<SolidColorBrush x:Key="ToolBarToggleButtonVerticalBackground" Color="#FFEEF5FD"/>
57-
<SolidColorBrush x:Key="ToolBarButtonHover" Color="#210080FF"/>
58-
<SolidColorBrush x:Key="ToolBarGripper" Color="#FF6D6D6D"/>
59-
<Style x:Key="ToolBarVerticalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
60-
<Setter Property="Background" Value="{StaticResource ToolBarToggleButtonVerticalBackground}"/>
61-
<Setter Property="MinHeight" Value="0"/>
62-
<Setter Property="MinWidth" Value="0"/>
63-
<Setter Property="Template">
64-
<Setter.Value>
65-
<ControlTemplate TargetType="{x:Type ToggleButton}">
66-
<Border x:Name="Bd" Background="{TemplateBinding Background}" CornerRadius="0,0,3,3" SnapsToDevicePixels="true">
67-
<Canvas Margin="2,7,2,2" HorizontalAlignment="Right" Height="6" Width="7" SnapsToDevicePixels="true" VerticalAlignment="Bottom">
68-
<Path Data="M 1.5 1 L 1.5 6" Stroke="White"/>
69-
<Path Data="M 0.5 0 L 0.5 5" Stroke="{TemplateBinding Foreground}"/>
70-
<Path Data="M 3.5 0.5 L 7 3.5 L 4 6.5 Z" Fill="White"/>
71-
<Path Data="M 3 -0.5 L 6 2.5 L 3 5.5 Z" Fill="{TemplateBinding Foreground}"/>
72-
</Canvas>
73-
</Border>
74-
<ControlTemplate.Triggers>
75-
<Trigger Property="IsMouseOver" Value="true">
76-
<Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
77-
</Trigger>
78-
<Trigger Property="IsKeyboardFocused" Value="true">
79-
<Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
80-
</Trigger>
81-
<Trigger Property="IsEnabled" Value="false">
82-
<Setter Property="Foreground" Value="{StaticResource ToolBarGripper}"/>
83-
</Trigger>
84-
</ControlTemplate.Triggers>
85-
</ControlTemplate>
86-
</Setter.Value>
87-
</Setter>
88-
<Style.Triggers>
89-
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
90-
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
91-
</DataTrigger>
92-
</Style.Triggers>
93-
</Style>
94-
<SolidColorBrush x:Key="ToolBarVerticalBackground" Color="#FFEEF5FD"/>
95-
<SolidColorBrush x:Key="ToolBarToggleButtonHorizontalBackground" Color="#FFEEF5FD"/>
96-
<Style x:Key="ToolBarHorizontalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
97-
<Setter Property="Background" Value="{StaticResource ToolBarToggleButtonHorizontalBackground}"/>
98-
<Setter Property="MinHeight" Value="0"/>
99-
<Setter Property="MinWidth" Value="0"/>
100-
<Setter Property="Template">
101-
<Setter.Value>
102-
<ControlTemplate TargetType="{x:Type ToggleButton}">
103-
<Border x:Name="Bd" Background="{TemplateBinding Background}" CornerRadius="0,3,3,0" SnapsToDevicePixels="true">
104-
<Canvas Margin="7,2,2,2" HorizontalAlignment="Right" Height="7" Width="6" SnapsToDevicePixels="true" VerticalAlignment="Bottom">
105-
<Path Data="M 1 1.5 L 6 1.5" Stroke="White"/>
106-
<Path Data="M 0 0.5 L 5 0.5" Stroke="{TemplateBinding Foreground}"/>
107-
<Path Data="M 0.5 4 L 6.5 4 L 3.5 7 Z" Fill="White"/>
108-
<Path Data="M -0.5 3 L 5.5 3 L 2.5 6 Z" Fill="{TemplateBinding Foreground}"/>
109-
</Canvas>
110-
</Border>
111-
<ControlTemplate.Triggers>
112-
<Trigger Property="IsMouseOver" Value="true">
113-
<Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
114-
</Trigger>
115-
<Trigger Property="IsKeyboardFocused" Value="true">
116-
<Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
117-
</Trigger>
118-
<Trigger Property="IsEnabled" Value="false">
119-
<Setter Property="Foreground" Value="{StaticResource ToolBarGripper}"/>
120-
</Trigger>
121-
</ControlTemplate.Triggers>
122-
</ControlTemplate>
123-
</Setter.Value>
124-
</Setter>
125-
<Style.Triggers>
126-
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
127-
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
128-
</DataTrigger>
129-
</Style.Triggers>
130-
</Style>
131-
<SolidColorBrush x:Key="ToolBarMenuBorder" Color="#FFB6BDC5"/>
132-
<SolidColorBrush x:Key="ToolBarSubMenuBackground" Color="#FFEEF5FD"/>
133-
<Style x:Key="ToolBarThumbStyle" TargetType="{x:Type Thumb}">
134-
<Setter Property="Template">
135-
<Setter.Value>
136-
<ControlTemplate TargetType="{x:Type Thumb}">
137-
<Border Background="Transparent" SnapsToDevicePixels="True" Padding="{TemplateBinding Padding}">
138-
<Rectangle>
139-
<Rectangle.Fill>
140-
<DrawingBrush TileMode="Tile" Viewbox="0,0,4,4" Viewport="0,0,4,4" ViewportUnits="Absolute" ViewboxUnits="Absolute">
141-
<DrawingBrush.Drawing>
142-
<DrawingGroup>
143-
<GeometryDrawing Brush="White" Geometry="M 1 1 L 1 3 L 3 3 L 3 1 z"/>
144-
<GeometryDrawing Brush="{StaticResource ToolBarGripper}" Geometry="M 0 0 L 0 2 L 2 2 L 2 0 z"/>
145-
</DrawingGroup>
146-
</DrawingBrush.Drawing>
147-
</DrawingBrush>
148-
</Rectangle.Fill>
149-
</Rectangle>
150-
</Border>
151-
<ControlTemplate.Triggers>
152-
<Trigger Property="IsMouseOver" Value="true">
153-
<Setter Property="Cursor" Value="SizeAll"/>
154-
</Trigger>
155-
</ControlTemplate.Triggers>
156-
</ControlTemplate>
157-
</Setter.Value>
158-
</Setter>
159-
</Style>
160-
<Style x:Key="ToolBarMainPanelBorderStyle" TargetType="{x:Type Border}">
161-
<Setter Property="Margin" Value="0,0,11,0"/>
162-
<Setter Property="CornerRadius" Value="3,3,3,3"/>
163-
<Style.Triggers>
164-
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
165-
<Setter Property="CornerRadius" Value="0,0,0,0"/>
166-
</DataTrigger>
167-
</Style.Triggers>
168-
</Style>
169-
<Style x:Key="MaterialDesignToolBar" TargetType="{x:Type ToolBar}">
170-
<Setter Property="Background" Value="{StaticResource ToolBarHorizontalBackground}"/>
171-
<Setter Property="Template">
172-
<Setter.Value>
173-
<ControlTemplate TargetType="{x:Type ToolBar}">
174-
<Grid x:Name="Grid" Margin="3,1,1,1" SnapsToDevicePixels="true">
175-
<Grid x:Name="OverflowGrid" HorizontalAlignment="Right">
176-
<ToggleButton x:Name="OverflowButton" ClickMode="Press" FocusVisualStyle="{x:Null}" IsChecked="{Binding IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" IsEnabled="{TemplateBinding HasOverflowItems}" Style="{StaticResource ToolBarHorizontalOverflowButtonStyle}"/>
177-
<Popup x:Name="OverflowPopup" AllowsTransparency="true" Focusable="false" IsOpen="{Binding IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom" StaysOpen="false">
178-
<Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent">
179-
<Border x:Name="ToolBarSubMenuBorder" BorderBrush="{StaticResource ToolBarMenuBorder}" BorderThickness="1" Background="{StaticResource ToolBarSubMenuBackground}" RenderOptions.ClearTypeHint="Enabled">
180-
<ToolBarOverflowPanel x:Name="PART_ToolBarOverflowPanel" KeyboardNavigation.DirectionalNavigation="Cycle" FocusVisualStyle="{x:Null}" Focusable="true" Margin="2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.TabNavigation="Cycle" WrapWidth="200"/>
181-
</Border>
182-
</Themes:SystemDropShadowChrome>
183-
</Popup>
184-
</Grid>
185-
<Border x:Name="MainPanelBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" Style="{StaticResource ToolBarMainPanelBorderStyle}">
186-
<DockPanel KeyboardNavigation.TabIndex="1" KeyboardNavigation.TabNavigation="Local">
187-
<Thumb x:Name="ToolBarThumb" Margin="-3,-1,0,0" Padding="6,5,1,6" Style="{StaticResource ToolBarThumbStyle}" Width="10"/>
188-
<ContentPresenter x:Name="ToolBarHeader" ContentSource="Header" HorizontalAlignment="Center" Margin="4,0,4,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
189-
<ToolBarPanel x:Name="PART_ToolBarPanel" IsItemsHost="true" Margin="0,1,2,2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
190-
</DockPanel>
191-
</Border>
192-
</Grid>
193-
<ControlTemplate.Triggers>
194-
<Trigger Property="IsOverflowOpen" Value="true">
195-
<Setter Property="IsEnabled" TargetName="ToolBarThumb" Value="false"/>
196-
</Trigger>
197-
<Trigger Property="Header" Value="{x:Null}">
198-
<Setter Property="Visibility" TargetName="ToolBarHeader" Value="Collapsed"/>
199-
</Trigger>
200-
<Trigger Property="ToolBarTray.IsLocked" Value="true">
201-
<Setter Property="Visibility" TargetName="ToolBarThumb" Value="Collapsed"/>
202-
</Trigger>
203-
<Trigger Property="HasDropShadow" SourceName="OverflowPopup" Value="true">
204-
<Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
205-
<Setter Property="SnapsToDevicePixels" TargetName="Shdw" Value="true"/>
206-
<Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
207-
</Trigger>
208-
<Trigger Property="Orientation" Value="Vertical">
209-
<Setter Property="Margin" TargetName="Grid" Value="1,3,1,1"/>
210-
<Setter Property="Style" TargetName="OverflowButton" Value="{StaticResource ToolBarVerticalOverflowButtonStyle}"/>
211-
<Setter Property="Height" TargetName="ToolBarThumb" Value="10"/>
212-
<Setter Property="Width" TargetName="ToolBarThumb" Value="Auto"/>
213-
<Setter Property="Margin" TargetName="ToolBarThumb" Value="-1,-3,0,0"/>
214-
<Setter Property="Padding" TargetName="ToolBarThumb" Value="5,6,6,1"/>
215-
<Setter Property="Margin" TargetName="ToolBarHeader" Value="0,0,0,4"/>
216-
<Setter Property="Margin" TargetName="PART_ToolBarPanel" Value="1,0,2,2"/>
217-
<Setter Property="DockPanel.Dock" TargetName="ToolBarThumb" Value="Top"/>
218-
<Setter Property="DockPanel.Dock" TargetName="ToolBarHeader" Value="Top"/>
219-
<Setter Property="HorizontalAlignment" TargetName="OverflowGrid" Value="Stretch"/>
220-
<Setter Property="VerticalAlignment" TargetName="OverflowGrid" Value="Bottom"/>
221-
<Setter Property="Placement" TargetName="OverflowPopup" Value="Right"/>
222-
<Setter Property="Margin" TargetName="MainPanelBorder" Value="0,0,0,11"/>
223-
<Setter Property="Background" Value="{StaticResource ToolBarVerticalBackground}"/>
224-
</Trigger>
225-
<Trigger Property="IsEnabled" Value="false">
226-
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
227-
</Trigger>
228-
</ControlTemplate.Triggers>
229-
</ControlTemplate>
230-
</Setter.Value>
231-
</Setter>
232-
<Style.Triggers>
233-
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
234-
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
235-
</DataTrigger>
236-
</Style.Triggers>
237-
</Style>
238-
239-
<Style x:Key="{x:Static ToolBar.ButtonStyleKey}" />
240-
<Style x:Key="{x:Static ToolBar.CheckBoxStyleKey}" />
241-
<Style x:Key="{x:Static ToolBar.ComboBoxStyleKey}" />
242-
<Style x:Key="{x:Static ToolBar.MenuStyleKey}" />
243-
<Style x:Key="{x:Static ToolBar.RadioButtonStyleKey}" />
244-
<Style x:Key="{x:Static ToolBar.SeparatorStyleKey}" />
245-
<Style x:Key="{x:Static ToolBar.TextBoxStyleKey}" />
246-
<Style x:Key="{x:Static ToolBar.ToggleButtonStyleKey}" />
247-
24855

249-
<Style x:Key="{x:Static ToolBar.ButtonStyleKey}" TargetType="Button">
250-
<Setter Property="Padding" Value="16"/>
251-
<Setter Property="HorizontalContentAlignment" Value="Center"/>
252-
<Setter Property="VerticalContentAlignment" Value="Center"/>
253-
<Setter Property="TextBlock.FontWeight" Value="DemiBold"/>
254-
<Setter Property="Template">
255-
<Setter.Value>
256-
<ControlTemplate TargetType="{x:Type Button}">
257-
<wpf:VisualFeedbackContentControl Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
258-
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
259-
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
260-
Padding="{TemplateBinding Padding}"
261-
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
262-
</ControlTemplate>
263-
</Setter.Value>
264-
</Setter>
265-
</Style>
26656

26757
</ResourceDictionary>
26858

@@ -368,20 +158,35 @@
368158
</Viewbox>
369159
</Button>
370160
<Separator />
371-
<Label Content="Font size:"/>
161+
<Label Content="Font size:" VerticalAlignment="Center"/>
372162
<ComboBox>
373163
<ComboBoxItem Content="10"/>
374164
<ComboBoxItem IsSelected="True" Content="12"/>
375165
<ComboBoxItem Content="14"/>
376166
<ComboBoxItem Content="16"/>
377167
</ComboBox>
168+
<CheckBox>
169+
Check
170+
</CheckBox>
378171
<Button ToolTip="Take a nap" ToolBar.OverflowMode="Always">
379172
<Viewbox Width="16" Height="16">
380173
<Canvas Width="24" Height="24">
381174
<Path Data="M19,7H11V14H3V5H1V20H3V17H21V20H23V11A4,4 0 0,0 19,7M7,13A3,3 0 0,0 10,10A3,3 0 0,0 7,7A3,3 0 0,0 4,10A3,3 0 0,0 7,13Z" Fill="Black" />
382175
</Canvas>
383176
</Viewbox>
384177
</Button>
178+
<RadioButton GroupName="XXX">
179+
Radio
180+
</RadioButton>
181+
<RadioButton GroupName="XXX">
182+
Ga Ga
183+
</RadioButton>
184+
<ToggleButton>
185+
Switch
186+
</ToggleButton>
187+
<Menu>
188+
<MenuItem>Embedded menu</MenuItem>
189+
</Menu>
385190
</ToolBar>
386191
</ToolBarTray>
387192
</DockPanel>

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@
140140
<SubType>Designer</SubType>
141141
<Generator>MSBuild:Compile</Generator>
142142
</Page>
143+
<Page Include="Themes\MaterialDesignTheme.ToolBar.xaml">
144+
<SubType>Designer</SubType>
145+
<Generator>MSBuild:Compile</Generator>
146+
</Page>
143147
</ItemGroup>
144148
<ItemGroup>
145149
<Compile Include="Card.cs" />

0 commit comments

Comments
 (0)