BarSubItemThemeSelectorBehavior

  • 2 minutes to read

The BarSubItemThemeSelectorBehavior is behavior that automatically populates the associated BarSubItem with all available themes and allows you to choose a theme applied to your application.

BarSubItemThemeSelectorBehavior

To use the BarSubItemThemeSelectorBehavior, attach it to a BarSubItem in a RibbonControl.

<dxb:BarSubItem ... >
    <dxmvvm:Interaction.Behaviors>
        <dxb:BarSubItemThemeSelectorBehavior />
    </dxmvvm:Interaction.Behaviors>
</dxb:BarSubItem>

The BarSubItemThemeSelectorBehavior allows you to choose the mode in which to display the BarSubItem items by setting the ShowMode property. Below is a list of supported modes.

  • List

    BarSubItemThemeSelectorBehavior_List

  • GroupedList

    BarSubItemThemeSelectorBehavior_GroupedList

  • GroupedInSubMenus

    BarSubItemThemeSelectorBehavior_GroupedInSubMenus

TIP

Use the static ApplicationThemeHelper.SaveApplicationThemeName method to save the current theme name (defined using the static ApplicationThemeHelper.ApplicationThemeName property) to the application configuration file. To retrieve the theme name from the configuration file, call the static ApplicationThemeHelper.UpdateApplicationThemeName method.

An example illustrating how to use this behavior.

<dxr:DXRibbonWindow
        x:Class="ThemeHelperWPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
        xmlns:dxr="http://schemas.devexpress.com/winfx/2008/xaml/ribbon" 
        xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"        
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
        xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
        Title="MainWindow" Height="350" Width="525">
    <DockPanel>
        <dxr:RibbonControl x:Name="RibbonControl" DockPanel.Dock="Top">
            <dxr:RibbonControl.PageHeaderItems>
                <dxb:BarEditItem                 
                        Content="Ribbon Style:" 
                        EditWidth="100" 
                        ClosePopupOnChangingEditValue="True" 
                        EditValue="{Binding RibbonStyle, ElementName=RibbonControl}">
                    <dxb:BarEditItem.EditSettings>
                        <dxe:ComboBoxEditSettings IsTextEditable="False" PopupMaxHeight="250">
                            <dxe:ComboBoxEditSettings.Items>
                                <dxr:RibbonStyle>Office2010</dxr:RibbonStyle>
                                <dxr:RibbonStyle>Office2007</dxr:RibbonStyle>
                            </dxe:ComboBoxEditSettings.Items>
                        </dxe:ComboBoxEditSettings>
                    </dxb:BarEditItem.EditSettings>
                </dxb:BarEditItem>
            </dxr:RibbonControl.PageHeaderItems>
            <dxr:RibbonDefaultPageCategory>
                <dxr:RibbonPage Caption="Home"/>
                <dxr:RibbonPage Caption="Settings" IsSelected="True">
                    <dxr:RibbonPageGroup Caption="Bar Split Item">
                        <dxb:BarSplitButtonItem 
                            Content="Themes" 
                            Glyph="{dx:DXImage Image=LoadTheme_16x16.png}" 
                            LargeGlyph="{dx:DXImage Image=LoadTheme_32x32.png}">
                            <dxmvvm:Interaction.Behaviors>
                                <dxb:BarSplitItemThemeSelectorBehavior/>
                            </dxmvvm:Interaction.Behaviors>
                        </dxb:BarSplitButtonItem>
                    </dxr:RibbonPageGroup>

                    <dxr:RibbonPageGroup Caption="Bar Sub Item">
                        <dxb:BarSubItem 
                            Content="Themes"
                            Glyph="{dx:DXImage Image=LoadTheme_16x16.png}"
                            LargeGlyph="{dx:DXImage Image=LoadTheme_32x32.png}">
                            <dxmvvm:Interaction.Behaviors>
                                <dxb:BarSubItemThemeSelectorBehavior ShowMode="GroupedInSubMenus"/>
                            </dxmvvm:Interaction.Behaviors>
                        </dxb:BarSubItem>
                    </dxr:RibbonPageGroup>

                    <dxr:RibbonPageGroup Caption="Ribbon Gallery Item">
                        <dxr:RibbonGalleryBarItem Content="Themes">
                            <dxmvvm:Interaction.Behaviors>
                                <dxr:RibbonGalleryItemThemeSelectorBehavior />
                            </dxmvvm:Interaction.Behaviors>
                            <dxr:RibbonGalleryBarItem.Gallery>
                                <dxb:Gallery ColCount="4"/>
                            </dxr:RibbonGalleryBarItem.Gallery>
                        </dxr:RibbonGalleryBarItem>
                    </dxr:RibbonPageGroup>

                </dxr:RibbonPage>
            </dxr:RibbonDefaultPageCategory>
        </dxr:RibbonControl>
    </DockPanel>
</dxr:DXRibbonWindow>
See Also