WPF樣式學習:ToolBar的使用
阿新 • • 發佈:2017-07-19
wpf rgs args framework use 拖動 圖標 align out
隱藏拖動把手:
設置ToolBar屬性 ToolBarTray.IsLocked="True",可以達到隱藏拖動把手的目的
private void ToolBar_Loaded(object sender, RoutedEventArgs e) { //去掉ToolBar右邊默認的擴展圖標 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(0); } }
<ToolBar x:Name="tbStuRelay" Width="120" ToolBarTray.IsLocked="True" Background="#008ede" HorizontalAlignment="Stretch" VerticalAlignment="Center" VerticalContentAlignment="Center" Loaded="ToolBar_Loaded" MouseMove="ToolBar_MouseMove" Visibility="Collapsed">
</ToolBar>
WPF樣式學習:ToolBar的使用