MaterialDesignInXamlToolkit
MaterialDesignInXamlToolkit copied to clipboard
Allow collapsing overflow area of ToolBar
Is your feature request related to a problem? Please describe. A ToolBar always contains the area for the overflow, even there is no overflow at all. I am not sure if this is intended behavior or no. For small toolbars I find this rather annoying.
Here a small example, the overflow part is the lighter area to the right of the ‘B’ button:
In the package code itself I can get achieve my expected result by changing ToolBarOverflowButtonVisibilityConverter
to return Visibility.Collapsed
instead of Visibility.Hidden
. But I guess that could cause issues in other use cases.
Describe the solution you'd like The behavior of the overflow area is configurable in XAML.
Describe alternatives you've considered My current workaround is to collapse the overflow grid using an implicit style:
<ToolBar.Resources>
<Style TargetType="{x:Type Grid}">
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</ToolBar.Resources>
This works only as long as there are no other uses of Grid.
Additional context This is based on to 4.5.0.
Can you provide us the xaml code of your example please ?
Can you provide us the xaml code of your example please ?
Sure, I have added it to the demo application here: https://github.com/krmr/MaterialDesignInXamlToolkit/blob/toolBarOverflow/MainDemo.Wpf/MenusAndToolBars.xaml (The background color is set to see the extend of the toolbar more easily.)
I think this is a good suggestion. I would propose this be an attached property in a new ToolBarAssist
class. I would expect the property to be an enum that follows a similar structure to the ScrollBarVisibility enum (default to Auto, but have members for force visibility).
What is the purpose of the OverFlowGrid? I feel like this grid is useless in the template.
@Keboo, thanks for your feedback. Actually I had thought along the same lines but was not really sure as the visibilty is set in ToolBarOverflowButtonVisibilityConverter
. So I guess it would either have to be an additional parameter for the converter or the converter would have to directly access ToolBarAssist
.
@Xaalek regarding the OverFlowGrid I have wondered as well but have not dug any further yet.
@krmr I checked the documentation and I saw that we can have overflow items with a button like this:
https://docs.microsoft.com/en-us/dotnet/desktop/wpf/controls/toolbar-overview?view=netframeworkdesktop-4.8#toolbars-with-overflow-items
I understand better the usefulness of this grid. Maybe we should just set the overflow area to collapsed when there are no overflow items.
Moreover, currently there is no example in the demo application. I think it would be nice to add an example with this mechanism.
@Xaalek I think the demo application already has overflow items but it might depend on the window size.
From my point of view we could always collapse the area if there are no overflow items. But that would change the behavior compared to how things are today. For that reason I like the idea of making it configurable as @Keboo proposed.
@krmr yes you're right. Thanks for the clarification.
Can be resolved by adding of Trigger in ControlTemplate of MaterialDesignToolBar
<Trigger Property="ToolBar.OverflowMode" Value="Never">
<Setter TargetName="OverflowGrid" Property="Visibility" Value="Collapsed" />
<Setter TargetName="MainPanelBorder" Property="Margin" Value="0,0,0,0" />
</Trigger>