Commanding with C1Toolbar (WPF Tutorial) > Part 1: Using the Command Library |
WPF provides a library of predefined commands such as the following:
Many WPF controls have built-in support for these commands so you can implement them without having to write code.
The following steps show how to implement some common clipboard commands using C1Toolbar.
XAML |
Copy Code
|
---|---|
<Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition /> </Grid.RowDefinitions> |
XAML |
Copy Code
|
---|---|
<c1:C1Toolbar Name="c1Toolbar1" FocusManager.IsFocusScope="True"> <c1:C1ToolbarTabControl> <c1:C1ToolbarTabItem Header="Home"> <c1:C1ToolbarGroup Header="Clipboard"> <c1:C1ToolbarButton LabelTitle="Paste" Command="ApplicationCommands.Paste" LargeImageSource="/Resources/paste.png" /> <c1:C1ToolbarButton LabelTitle="Cut" Command="ApplicationCommands.Cut" SmallImageSource="/Resources/cut.png" /> <c1:C1ToolbarButton LabelTitle="Copy" Command="ApplicationCommands.Copy" SmallImageSource="/Resources/copy.png" /> </c1:C1ToolbarGroup> </c1:C1ToolbarTabItem> </c1:C1ToolbarTabControl> </c1:C1Toolbar> |
This markup creates a single tab containing a single group inside C1Toolbar. The Clipboard group contains three C1ToolbarButtons each assigned a common clipboard command from the WPF application command library. Notice the attached IsFocusScope property is set to True for C1Toolbar. This enables C1Toolbar to keep track of the focused element within its scope. Small and large images are also specified for the C1ToolbarButtons, although these are not required.