Back to Devexpress

BarItemSelector Class

wpf-devexpress-dot-xpf-dot-bars-feae0662.md

latest3.5 KB
Original Source

BarItemSelector Class

A container for bar items that can have only one selected item.

Namespace : DevExpress.Xpf.Bars

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

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public class BarItemSelector :
    BarLinkContainerItem
vb
Public Class BarItemSelector
    Inherits BarLinkContainerItem

Remarks

You can use the BarItemSelector to group BarCheckItems. Once a user checks an item, the selector unchecks the previously selected item.

xaml
<dxb:ToolBarControl>
    <dxb:BarItemSelector>
        <dxb:BarCheckItem Glyph="{dx:DXImage 'SvgImages/Icon Builder/Actions_Question.svg'}"/>
        <dxb:BarCheckItem Glyph="{dx:DXImage 'SvgImages/Icon Builder/Security_Warning.svg'}"/>
        <dxb:BarCheckItem Glyph="{dx:DXImage 'SvgImages/Icon Builder/Security_WarningCircled1.svg'}"/>
    </dxb:BarItemSelector>
</dxb:ToolBarControl>

The BarItemSelector does not allow users to uncheck items. Set the AllowEmptySelection property to true to change this behavior.

Generate Items from the View Model

The BarItemSelector can obtain its items from the View Model collection:

  1. Create a collection of items that should be displayed in the BarItemSelector:

  2. Bind the ItemLinksSource property to the created collection.

  3. Specify a template that generates items and assign it to the ItemTemplate property.

  4. The SelectedItem property allows you to define a checked item in the View Model.

xaml
<dxb:BarSubItem Content="Priority">
    <dxb:BarItemSelector ItemLinksSource="{Binding Priorities}"
                         SelectedItem="{Binding SelectedPriority}">
        <dxb:BarItemSelector.ItemTemplate>
            <DataTemplate>
                <ContentControl>
                    <dxb:BarCheckItem Content="{Binding Name}"/>
                </ContentControl>
            </DataTemplate>
        </dxb:BarItemSelector.ItemTemplate>
    </dxb:BarItemSelector>
</dxb:BarSubItem>

Implements

IControllerAction

ILinksHolder

Inheritance

Object DispatcherObject DependencyObject ContentElement FrameworkContentElement BarItem BarLinkContainerItem BarItemSelector

See Also

BarItemSelector Members

DevExpress.Xpf.Bars Namespace