Posted by: Zeeshan Amjad | February 17, 2010

Using Built in Commands with Tool bar

We already saw the example of command binding here. WPF already provide few commands as defined in this block diagram.


Now we are going to use the built in command with tool bar. Using built in commands with tool bare is in fact very easy. Unlike the command button, we don’t have to provide the command target here. If we don’t provide the command target then the current focus UIElement will be a command target. Here is one very simple program to demonstrate the built in command binding with tool bar.

  1: <Window x:Class="WpfToolBar.Window1"
  2:     xmlns=""
  3:     xmlns:x=""
  4:     Title="Toolbar" Height="300" Width="400">
  5:     <DockPanel>
  6:         <ToolBar DockPanel.Dock="Top">
  7:             <Button Content="Cut" Command="ApplicationCommands.Cut"/>
  8:             <Button Content="Copy" Command="ApplicationCommands.Copy"/>
  9:             <Button Content="Paste" Command="ApplicationCommands.Paste"/>
 10:         </ToolBar>
 11:         <Grid>
 12:             <TextBox Margin="5" TextWrapping="Wrap" />
 13:         </Grid>
 14:     </DockPanel>
 15: </Window>

Here is the output of this program.



  1. […] bar is not very difficult. We have already made one program of using built in command with tool bar here. Now we are going to extend this program and introduce one combo box to select the foreground color […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: