In a nested WPF ToolBarPanel-ToolBar-Menu we want to get rid of the grip handle to the left and the overflow area to the right. they are both grayed out, but we'd like them to not be displayed at all.
any ideas on how to accomplish that?
just in case my terms aren't entirely correct, if you look at the image in Figure 3 of the link below, on the lowest of the three toolbars there's the grip to the left of the dropdown and to the right of the right-most button there's the overflow.
Image of toolbars
The grip can be removed by setting the attached property ToolBarTray.IsLocked="True"
on the ToolBar.
To remove the Overflow ToggleButton, you will have to remove it in a custom ControlTemplate as sixlettervariables suggests, which if you have blend or can download the Blend 3 Preview is not overly difficult.
You could also just hide the button in the loaded event of the ToolBar, though whichever route you take, you should also set the attached property ToolBar.OverflowMode="Never"
on the ToolBar's menu, so that items cannot accidentally overflow into an unreachable area.
<ToolBarPanel DockPanel.Dock="Top"> <ToolBar ToolBarTray.IsLocked="True" Loaded="ToolBar_Loaded"> <Menu ToolBar.OverflowMode="Never"> <MenuItem Header="File" /> <MenuItem Header="New" /> </Menu> </ToolBar> </ToolBarPanel>
And set the Overflow ToggleButton to collapsed:
private void ToolBar_Loaded(object sender, RoutedEventArgs e) { ToolBar toolBar = sender as ToolBar; var overflowGrid = toolBar.Template.FindName("OverflowGrid", toolBar) as FrameworkElement; if (overflowGrid != null) { overflowGrid.Visibility = Visibility.Collapsed; } var mainPanelBorder = toolBar.Template.FindName("MainPanelBorder", toolBar) as FrameworkElement; if (mainPanelBorder != null) { mainPanelBorder.Margin = new Thickness(); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With