Skip to main content

How to: Create Bar Button Items and Add Separators Between Links

  • 2 minutes to read

This example shows how to create bar button items (BarButtonItem objects) and add a link separator between them. The separator is created using the BarItemLinkSeparator class.

The following image shows the result:


View Example

<Window xmlns="" 
        Title="Window1" Height="300" Width="300">
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*"/>

        <dxb:BarContainerControl Grid.Row="0">
            <dxb:ToolBarControl Caption="Main Toolbar"  BarItemHorizontalIndent="10">
                <dxb:BarButtonItem Content="Undo" Glyph="{dx:DXImage Image=undo16x16.png}" ItemClick="itemClick"/>
                <dxb:BarButtonItem Content="Redo" Glyph="{dx:DXImage Image=redo16x16.png}" ItemClick="itemClick"/>
                <dxb:BarItemLinkSeparator />
                <dxb:BarButtonItem Content="Copy" Glyph="{dx:DXImage Image=copy16x16.png}" ItemClick="itemClick"/>
                <dxb:BarButtonItem Content="Paste" Glyph="{dx:DXImage Image=paste16x16.png}" ItemClick="itemClick"/>

        <RichTextBox Grid.Row="1"/>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BarItemLinkSeparatorEx {
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window {
        public Window1() {

        // Respond to clicking the bar items
        private void itemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e) {
            MessageBox.Show("Item " + e.Item.Content + " has been clicked.");