Adding a toolbar panel to perform quick tasks
In any windows-based application, you can find a toolbar, usually placed just below the main menu of a window. It contains a set of controls to provide easy access to common functions.
WPF offers you a ToolBarTray
element to host one or more ToolBar
controls, containing various UI controls. It provides you with some extra features, such as an automatic overflowing mechanism and a manual repositioning feature.
In this recipe, we will learn how to work with toolbars in a WPF application.
Getting ready
To begin with, open your Visual Studio IDE and create a new WPF application project called CH03.ToolBarDemo
.
How to do it...
Once the project gets created, follow these steps to add a toolbar in the application window:
- Open the
MainWindow.xaml
page from theSolution Explorer
. - Now, replace the existing
Grid
with aDockPanel
so that we can host the toolbar docking to the top of the window. - Add a
ToolBarTray
element inside theDockPanel
and dock it toTop
. - Add...