In Code-behind, I make sure to handle the CanExecute event of the first three buttons, since that's not done automatically by
Each contains some buttons and we use commands to
In this example, I add a ToolBarTray to the top of the screen, and inside of it, two ToolBar controls. Look at the Menu chapter, or the articles on commands, for more information. We discussed this in the previous chapter and using commands definitely gives us some advantages. Notice how I use commands for all the buttons. Private void CommonCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e) Public partial class ToolbarSample : Window Namespace WpfTutorialSamples.Common_interface_controls Let's try a pretty basic example, to see what it all looks like: ToolBar controls inside of the ToolBarTray element. The ToolBarTray will handle stuff like placement and sizing, and you can have multiple This could in fact be a simple panel withīuttons on it, but by using the WPF ToolBar control, you get some extra goodies like automatic overflow handling and the possibility for the end-user toĪ WPF ToolBar is usually placed inside of a ToolBarTray control. The toolbar is a row of commands, usually sitting right below the main menu of a standard Windows application. Common interface controls: The WPF ToolBar control