Skip to main content
A newer version of this page is available. .
Bar

BarContainerControl.Bars Property

Stores bar objects displayed by the current BarContainerControl.

Namespace: DevExpress.Xpf.Bars

Assembly: DevExpress.Xpf.Core.v20.2.dll

NuGet Packages: DevExpress.WindowsDesktop.Wpf.Core, DevExpress.Wpf.Core

Declaration

public ObservableCollection<IBar> Bars { get; }

Property Value

Type Description
ObservableCollection<DevExpress.Xpf.Bars.Native.IBar>

A collection of bar objects displayed by the current BarContainerControl.

Remarks

This property is marked with the System.Windows.Markup.ContentPropertyAttribute attribute. So in XAML, objects defined between the BarContainerControl start and end tags are added to the Bars collection.

Elements of the Bars collection can be ToolBarControl, MainMenuControl, StatusBarControl and Bar objects.

Combining bar objects in a BarContainerControl serves the following purposes:

  • bar objects are automatically arranged without overlapping.
  • the drag-and-drop functionality is enabled for bars (except for main menus and status bars).

The following code places two bars in a BarContainerControl

<dxb:BarContainerControl>
    <dxb:ToolBarControl>
        <dxb:BarButtonItem Content="First"/>
        <dxb:BarButtonItem Content="Second"/>
    </dxb:ToolBarControl>
    <dxb:Bar>
        <dxb:BarButtonItem Content="Third"/>
    </dxb:Bar>            
</dxb:BarContainerControl>

For Bar objects defined within a BarContainerControl, you can still use the Bar.DockInfo property (DockInfo.Column and DockInfo.Row) to specify the bar’s position.

The following code adds two Bar objects to a BarContainerControl. The first bar is defined in the BarManager.Bars collection. The second bar is defined in the Bars collection. Note the BarDockInfo.Column property set for these Bars to custom arrange them within the BarContainerControl.

Note

If two bars are defined in the BarManager.Bars and BarContainerControl.Bars collection, respectively, and they have the same DockInfo.Row and DockInfo.Column settings, the bar placed inside the BarContainerControl.Bars collection will be displayed first, followed by the second bar.

<dxb:BarManager>
    <dxb:BarManager.Bars>
        <dxb:Bar DockInfo="{dxb:DockInfo ContainerName=barContainer, Column=0}">
            <dxb:BarButtonItem Content="Item1"/>
            <dxb:BarButtonItem Content="Item2"/>
        </dxb:Bar>
    </dxb:BarManager.Bars>
    <dxb:BarContainerControl x:Name="barContainer">
        <dxb:Bar DockInfo="{dxb:DockInfo Column=1}">
            <dxb:BarButtonItem Content="Item3"/>
            <dxb:BarButtonItem Content="Item4"/>
        </dxb:Bar>
    </dxb:BarContainerControl>
</dxb:BarManager>
See Also