Items and Links

  • 3 minutes to read

Overview

All elements displayed by Bars, Ribbon and Menus are represented by bar items and bar item links.

This topic includes the following sections.

  • Bar Items

    Bar items represent buttons, editors, static items, galleries and item containers.

     

  • Bar Item Links

    Bar item links represent bar items defined at another location.

     

Bar Items

Bar items are buttons, sub-menus, static text, editors, and other elements. They can be added directly to toolbars (ToolBarControl, MainMenuControl, StatusBarControl and Bar objects), sub-menus (BarSubItem), popup menus (PopupMenu and RadialContextMenu) and the RibbonControl.

Bar items are BarItem class descendants. A typical bar item is a button, represented by the BarButtonItem class. Clicking this item fires the BarItem.ItemClick and BarManager.ItemClick events, and also invokes the command assigned to the BarItem.Command property. Other bar item types are described in the The List of Bar Items and Links topic.

xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars" 
...
<dxb:ToolBarControl VerticalAlignment="Top"> 
    <dxb:BarButtonItem Content="Cut"/> 
    <dxb:BarButtonItem Content="Copy"/> 
    <dxb:BarButtonItem Content="Paste"/> 
</dxb:ToolBarControl>

When using the BarManager component, you can create bar items in the BarManager.Items collection. This collection can be regarded as the storage of bar items common to all bars and menus. Using this collection is optional from version 2014.2.

To logically organize bar items, you can assign them to categories. Categories will help an end-user to locate items at runtime using the Customization Window.

There might be cases when a single bar item should be used in multiple locations (bars, popup menus, etc.). To address this task, bar item links can be used.

A bar item link is a BarItemLink descendant instance that refers to a bar item defined in another location. For instance, you can create an "Open File" bar item that invokes the "Open File" dialog. Then you can add a link to this item within the main menu and add another link to the same item in a toolbar. To associate a bar item link with a specific bar item, use the BarItem.BarItemName property.

Like bar items, bar item links can be added as elements to bars, sub-menus, popup menus and Ribbon controls. The bar item link's look-and-feel and functionality are determined by the associated bar item object.

Bar items provide settings to control the default look of its bar item links. They have properties to specify the default caption, glyph, editor width (for edit items), etc. However, you can override these settings for each bar item link.

The following example creates the Edit toolbar. Elements of this toolbar are three bar item links that refer to the items defined in the BarManager.Items collection.

<dxb:BarManager>
    <dxb:BarManager.Items>
        <dxb:BarButtonItem x:Name="biCut" Content="Cut" Glyph="{dx:DXImage Image=Cut_16x16.png}" LargeGlyph="{dx:DXImage Image=Cut_32x32.png}"/>
        <dxb:BarButtonItem x:Name="biCopy" Content="Copy" Glyph="{dx:DXImage Image=Copy_16x16.png}" LargeGlyph="{dx:DXImage Image=Copy_32x32.png}"/>
        <dxb:BarButtonItem x:Name="biPaste" Content="Paste" Glyph="{dx:DXImage Image=Paste_16x16.png}" LargeGlyph="{dx:DXImage Image=Paste_32x32.png}"/>
    </dxb:BarManager.Items>
    <dxb:BarManager.Bars>
        <dxb:Bar Caption="Edit">
            <dxb:BarButtonItemLink BarItemName="biCut"/>
            <dxb:BarButtonItemLink BarItemName="biCopy"/>
            <dxb:BarButtonItemLink BarItemName="biPaste"/>
        </dxb:Bar>

    </dxb:BarManager.Bars>
    <Grid/>
</dxb:BarManager>

To access all bar item links for a bar item, use the BarItem.Links property.

Examples

See Also