Skip to content

Commit 8e31f23

Browse files
committed
restore the list box tool toggle back to it's original size, and break out the one uses in menus to the menu specific style
1 parent bdef90a commit 8e31f23

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

MainDemo.Wpf/Buttons.xaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@
293293
</ToggleButton>
294294
</StackPanel>
295295

296+
<!-- the following based on https://material.io/guidelines/components/buttons.html#buttons-toggle-buttons -->
296297
<ListBox Grid.Column="1" Grid.Row="0" Style="{StaticResource MaterialDesignToolToggleListBox}" SelectedIndex="0">
297298
<ListBox.ToolTip>
298299
<StackPanel>
@@ -314,6 +315,24 @@
314315
<materialDesign:PackIcon Kind="FormatAlignJustify"/>
315316
</ListBoxItem>
316317
</ListBox>
318+
<ListBox Grid.Column="1" Grid.Row="2" SelectionMode="Extended" Style="{StaticResource MaterialDesignToolToggleFlatListBox}">
319+
<ListBox.ToolTip>
320+
<StackPanel>
321+
<TextBlock Text="MaterialDesignToolToggleListBox" />
322+
<TextBlock Text="Multiple selection" />
323+
<TextBlock Text="ListBoxAssist.IsToggle allows more natural toggle behaviour" />
324+
</StackPanel>
325+
</ListBox.ToolTip>
326+
<ListBoxItem>
327+
<materialDesign:PackIcon Kind="FormatBold"/>
328+
</ListBoxItem>
329+
<ListBoxItem>
330+
<materialDesign:PackIcon Kind="FormatItalic"/>
331+
</ListBoxItem>
332+
<ListBoxItem x:Name="UnderlineCheckbox">
333+
<materialDesign:PackIcon Kind="FormatUnderline"/>
334+
</ListBoxItem>
335+
</ListBox>
317336
</Grid>
318337

319338
<Border Grid.Row="6" Margin="0 16 0 0" BorderThickness="0 1 0 0" BorderBrush="{DynamicResource MaterialDesignDivider}" />

MainDemo.Wpf/MenusAndToolBars.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@
7070
<materialDesign:PackIcon Kind="ContentPaste" />
7171
</Button>
7272
<Separator/>
73-
<ListBox Style="{StaticResource MaterialDesignToolToggleFlatListBox}">
73+
<ListBox>
7474
<ListBoxItem ToolTip="This is a lonley toggle with TextBlock instead of icon">
7575
<TextBlock>W</TextBlock>
7676
</ListBoxItem>
7777
</ListBox>
7878
<Separator/>
79-
<ListBox Style="{StaticResource MaterialDesignToolToggleFlatListBox}" SelectedIndex="0">
79+
<ListBox SelectedIndex="0">
8080
<ListBox.ToolTip>
8181
<StackPanel>
8282
<TextBlock Text="MaterialDesignToolToggleFlatListBox" />
@@ -98,7 +98,7 @@
9898
</ListBoxItem>
9999
</ListBox>
100100
<Separator/>
101-
<ListBox SelectionMode="Extended" Style="{StaticResource MaterialDesignToolToggleFlatListBox}">
101+
<ListBox SelectionMode="Extended">
102102
<ListBox.ToolTip>
103103
<StackPanel>
104104
<TextBlock Text="MaterialDesignToolToggleListBox" />

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ListBox.xaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@
2626
<Setter Property="Background" Value="Transparent"/>
2727
<Setter Property="BorderThickness" Value="0"/>
2828
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignDivider}"/>
29-
<Setter Property="TextBlock.FontWeight" Value="DemiBold"/>
30-
<Setter Property="TextBlock.FontSize" Value="18"/>
31-
<Setter Property="MinWidth" Value="54"/>
32-
<Setter Property="HorizontalContentAlignment" Value="Center"/>
29+
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
3330
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
34-
<Setter Property="Padding" Value="16" />
31+
<Setter Property="Padding" Value="14 6 14 6" />
3532
<Setter Property="SnapsToDevicePixels" Value="True"/>
3633
<Setter Property="Template">
3734
<Setter.Value>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToolBar.xaml

Lines changed: 14 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.Button.xaml" />
1313
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.ToggleButton.xaml" />
1414
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.Font.xaml" />
15+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.ListBox.xaml" />
1516
</ResourceDictionary.MergedDictionaries>
1617

1718
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
@@ -131,6 +132,19 @@
131132
<Setter Property="Width" Value="22" />
132133
<Setter Property="Height" Value="22" />
133134
</Style>
135+
<Style TargetType="ListBox" BasedOn="{StaticResource MaterialDesignToolToggleFlatListBox}">
136+
<Setter Property="ItemContainerStyle">
137+
<Setter.Value>
138+
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MaterialDesignToolToggleListBoxItem}">
139+
<Setter Property="TextBlock.FontWeight" Value="DemiBold"/>
140+
<Setter Property="TextBlock.FontSize" Value="18"/>
141+
<Setter Property="MinWidth" Value="54"/>
142+
<Setter Property="HorizontalContentAlignment" Value="Center"/>
143+
<Setter Property="Padding" Value="16" />
144+
</Style>
145+
</Setter.Value>
146+
</Setter>
147+
</Style>
134148
</ControlTemplate.Resources>
135149
<DockPanel x:Name="Grid" Margin="3,1,1,1" SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
136150
<Grid DockPanel.Dock="Right" x:Name="OverflowGrid" HorizontalAlignment="Right">

0 commit comments

Comments
 (0)