上面的图是两个工具栏的链接处。
去除蓝色部分的方法是
设置工具栏的ToolBarTray.IsLocked附加选项为True
去除红色部分
这个需要修改空间模板,比较麻烦。一个解决方案是在ToolBar的Loaded事件中做如下处理
1: private void ToolBar_Loaded(object sender, RoutedEventArgs e)
2: {
3: ToolBar toolBar = sender as ToolBar;
4: var overflowGrid = toolBar.Template.FindName("OverflowGrid", toolBar) as FrameworkElement;
5: if(overflowGrid != null)
6: {
7: overflowGrid.Visibility = Visibility.Collapsed;
8: }
9:
10: var mainPanelBorder = toolBar.Template.FindName("MainPanelBorder", toolBar) as FrameworkElement;
11: if(mainPanelBorder != null)
12: {
13: mainPanelBorder.Margin = new Thickness(0);
14: }
15: }