Skip to content

Commit f945917

Browse files
committed
only show toolbar overflow button if necessary
1 parent e56afb6 commit f945917

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToolBar.xaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.ToggleButton.xaml" />
1313
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.Font.xaml" />
1414
</ResourceDictionary.MergedDictionaries>
15+
16+
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
1517

1618
<Style x:Key="MaterialDesignToolBarVerticalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
1719
<Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}"/>
@@ -125,7 +127,10 @@
125127
<ControlTemplate TargetType="{x:Type ToolBar}">
126128
<DockPanel x:Name="Grid" Margin="3,1,1,1" SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
127129
<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 MaterialDesignToolBarHorizontalOverflowButtonStyle}"
130+
<ToggleButton x:Name="OverflowButton" ClickMode="Press" FocusVisualStyle="{x:Null}"
131+
IsChecked="{Binding IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
132+
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=HasOverflowItems, Converter={StaticResource BooleanToVisibilityConverter}}"
133+
Style="{StaticResource MaterialDesignToolBarHorizontalOverflowButtonStyle}"
129134
Foreground="{TemplateBinding Foreground}"
130135
/>
131136
<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">

0 commit comments

Comments
 (0)