Back to Devexpress

BarSplitButtonItem Class

wpf-devexpress-dot-xpf-dot-bars-9f3d1fe6.md

latest7.5 KB
Original Source

BarSplitButtonItem Class

Represents a bar button item supporting the drop-down functionality.

Namespace : DevExpress.Xpf.Bars

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

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public class BarSplitButtonItem :
    BarButtonItem
vb
Public Class BarSplitButtonItem
    Inherits BarButtonItem

Remarks

The BarSplitButtonItem supports the drop-down functionality, displaying a drop-down window when clicking the item link. The BarSplitButtonItem contains the main button, displaying the item’s content and glyph, and a Down Arrow button. Clicking the main button invokes the ItemClick events (BarItem.ItemClick and BarManager.ItemClick) and a command (BarItem.Command). Clicking the Down Arrow button invokes the drop-down control, specified by the BarSplitButtonItem.PopupControl property.

You can hide the Down Arrow button via the BarSplitButtonItem.ActAsDropDown property. In this instance, clicking the main button invokes the ItemClick events and the specified command. And in addition, the assigned drop-down control pops up.

BarSplitButtonItem can be used to implement a sub-menu in a RadialContextMenu.

Example

This example creates a BarSplitButtonItem (a button with drop-down). Click the button’s down arrow to display a popup window. To add a custom popup content, use the PopupControlContainer as the PopupControl.

The following image shows the result:

xaml
<dxb:BarContainerControl>
    <dxb:ToolBarControl UseWholeRow="True">
        <dxb:BarSplitButtonItem Name="btnFontColor" Content="FontColor" Glyph="{dx:DXImage Image=ChangeFontStyle_16x16.png}" ArrowAlignment="Bottom" ItemClick="btnFontColor_ItemClick">
            <dxb:BarSplitButtonItem.PopupControl>
                <dxb:PopupControlContainer>
                    <UserControl>
                        <dxe:ColorChooser/>
                    </UserControl>
                </dxb:PopupControlContainer>
            </dxb:BarSplitButtonItem.PopupControl>
        </dxb:BarSplitButtonItem>
    </dxb:ToolBarControl>
</dxb:BarContainerControl>
csharp
private void btnFontColor_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e) {
    PopupControlContainer pcc = (e.Item as DevExpress.Xpf.Bars.BarSplitButtonItem).PopupControl as PopupControlContainer;
    Color color = ((pcc.Content as UserControl).Content as ColorChooser).Color;
    MessageBox.Show("Color is applied: " + color.ToString());
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the BarSplitButtonItem class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-spreadsheet-assign-custom-in-place-editors/CS/WpfSpreadsheet_CustomCellEditors/MainWindow.xaml#L517

xml
<dxb:BarButtonItem x:Name="biInsertPicture" Command="{Binding InsertPicture, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarSplitButtonItem x:Name="biInsertChartColumnCommandGroup" ActAsDropDown="True" Command="{Binding InsertChartColumnCommandGroup, Mode=OneTime, Source={StaticResource commands}}">
    <dxr:GalleryDropDownPopupMenu>

wpf-spreadsheet-bind-spreadsheet-to-ms-sql-server-database/CS/WpfSpreadsheet_BindToDataSource/MainWindow.xaml#L519

xml
<dxb:BarButtonItem x:Name="biInsertPicture" Command="{Binding InsertPicture, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarSplitButtonItem x:Name="biInsertChartColumnCommandGroup" ActAsDropDown="True" Command="{Binding InsertChartColumnCommandGroup, Mode=OneTime, Source={StaticResource commands}}">
    <dxr:GalleryDropDownPopupMenu>

wpf-diagram-mdi/CS/MainWindow.xaml#L85

xml
<dxb:BarButtonItem dxdiag:DiagramDesignerControl.BarItemName="{x:Static dxdiag:DefaultBarItemNames.ShowPrintPreview}" Style="{StaticResource {dxdiagt:DesignerControlCommandsThemeKeys ResourceKey=ShowPrintPreviewCommandItemStyle}}" />
<dxb:BarSplitButtonItem dxdiag:DiagramDesignerControl.BarItemName="{x:Static dxdiag:DefaultBarItemNames.PrintMenu}" Style="{StaticResource {dxdiagt:DiagramDesignerControlThemeKeys ResourceKey=PrintMenuStyle}}">
    <dxb:PopupMenu>

wpf-create-a-fluent-design-using-appearance-options/CS/FluentDesignTemplate/MainWindow.xaml#L58

xml
</dx:WpfSvgPalette.Palette>
<dxb:BarSplitButtonItem Content="Alex" ActAsDropDown="True" BarItemDisplayMode="ContentAndGlyph" Glyph="{dx:DXImage SvgImages/Business Objects/BO_Customer.svg}">
    <dxb:PopupMenu>

wpf-mvvm-behaviors-barItems-based-theme-selectors/CS/WpfApplication1/MainWindow.xaml#L39

xml
<dxr:RibbonPageGroup Caption="Bar Split Item">
    <dxb:BarSplitButtonItem
        Content="Themes"

Implements

IControllerAction

Inheritance

Object DispatcherObject DependencyObject ContentElement FrameworkContentElement BarItem BarButtonItem BarSplitButtonItem BarSplitCheckItem

See Also

BarSplitButtonItem Members

Items and Links

DevExpress.Xpf.Bars Namespace