The ToolBar control is typically used to group together many small buttons or other controls as an enhancement to a traditional menu system.
This ToolBar example is adopted from Adam Nathan’s book WPF 4.5 Unleashed, on page 304. The buutons do not work. This is just an illustration of how to create a ToolBar. This text is in a TextBlock, which is inside a StackPanel. ToolBars can contain Labels, Separators, Images, ComboBoxes and others.
The buttons are small gif files that I downloaded from the book’s website when I downloaded the source code. Below is the XAML source code, modified only slightly from Adam’s code.
<Window x:Class="ToolBarSimple.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:ToolBarSimple" mc:Ignorable="d" WindowStartupLocation="CenterScreen" Title="ToolBarSimple" Height="200" Width="550"> <StackPanel> <ToolBar> <Label>adopted from Adam Nathan</Label> <Separator/> <Button Name="Copy" Click="Copy_Click" RenderOptions.BitmapScalingMode="NearestNeighbor"> <Image Source="copy.gif"/> </Button> <Separator/> <ToggleButton RenderOptions.BitmapScalingMode="NearestNeighbor"> <Image Source="bold.gif"/> </ToggleButton> <ToggleButton RenderOptions.BitmapScalingMode="NearestNeighbor"> <Image Source="italic.gif"/> </ToggleButton> <ToggleButton RenderOptions.BitmapScalingMode="NearestNeighbor"> <Image Source="underline.gif"/> </ToggleButton> <Separator/> <ToggleButton RenderOptions.BitmapScalingMode="NearestNeighbor"> <Image Source="left.gif"/> </ToggleButton> <ToggleButton RenderOptions.BitmapScalingMode="NearestNeighbor"> <Image Source="right.gif"/> </ToggleButton> <ToggleButton RenderOptions.BitmapScalingMode="NearestNeighbor"> <Image Source="justify.gif"/> </ToggleButton> <Separator/> <Label>Zoom</Label> <ComboBox SelectedIndex="0"> <ComboBoxItem>100%</ComboBoxItem> <ComboBoxItem>75%</ComboBoxItem> <ComboBoxItem>50%</ComboBoxItem> <ComboBoxItem>25%</ComboBoxItem> </ComboBox> <Separator/> <Button RenderOptions.BitmapScalingMode="NearestNeighbor"> <Image Source="superscript.gif"/> </Button> <Button RenderOptions.BitmapScalingMode="NearestNeighbor"> <Image Source="subscript.gif"/> </Button> </ToolBar> <TextBlock TextWrapping="Wrap" Margin="4">This ToolBar example is adopted from Adam Nathan's book WPF 4.5 Unleashed, on page 304. The buutons do not work. This is just an illustration of how to create a ToolBar. This text is in a TextBlock, which is inside a StackPanel. ToolBars can contain Labels, Separators, Images, ComboBoxes and others.</TextBlock> </StackPanel> </Window>