Back to Devexpress

RibbonGalleryItemThemePaletteSelectorBehavior Class

wpf-devexpress-dot-xpf-dot-ribbon-75f63917.md

latest7.4 KB
Original Source

RibbonGalleryItemThemePaletteSelectorBehavior Class

Populates the associated RibbonGalleryBarItem with the available palettes and allows you to choose the application theme’s palette.

Namespace : DevExpress.Xpf.Ribbon

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

NuGet Package : DevExpress.Wpf.Ribbon

Declaration

csharp
[TargetType(typeof(RibbonGalleryBarItem))]
public class RibbonGalleryItemThemePaletteSelectorBehavior :
    RibbonGalleryItemThemeSelectorBehavior
vb
<TargetType(GetType(RibbonGalleryBarItem))>
Public Class RibbonGalleryItemThemePaletteSelectorBehavior
    Inherits RibbonGalleryItemThemeSelectorBehavior

Remarks

Attach the RibbonGalleryItemThemePaletteSelectorBehavior to a RibbonGalleryBarItem in a RibbonControl to use it.

xaml
<dx:ThemedWindow
        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:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
        Title="MainWindow" Height="350" Width="525" 
        WindowKind="Ribbon" >
    <Grid>
        <dxr:RibbonControl x:Name="RibbonControl" DockPanel.Dock="Top">
            <dxr:RibbonDefaultPageCategory>
                <dxr:RibbonPage Caption="Home"/>
                <dxr:RibbonPage Caption="Settings" IsSelected="True">
                    <dxr:RibbonPageGroup Caption="Themes">
                        <dxr:RibbonGalleryBarItem>
                            <dxmvvm:Interaction.Behaviors>
                                <dxr:RibbonGalleryItemThemeSelectorBehavior ShowTouchThemes="False"/>
                            </dxmvvm:Interaction.Behaviors>
                        </dxr:RibbonGalleryBarItem>
                        <dxr:RibbonGalleryBarItem>
                            <dxmvvm:Interaction.Behaviors>
                                <dxr:RibbonGalleryItemThemePaletteSelectorBehavior />
                            </dxmvvm:Interaction.Behaviors>
                        </dxr:RibbonGalleryBarItem>
                    </dxr:RibbonPageGroup>
                </dxr:RibbonPage>
            </dxr:RibbonDefaultPageCategory>
        </dxr:RibbonControl>
    </Grid>
</dx:ThemedWindow>

View Example

Persist Theme Selection between Application Runs

You can save the application’s theme and palette to the configuration file and restore them on the next application run.

To save an applied theme and palette, use the static ApplicationThemeHelper.SaveApplicationThemeName method to save the theme name specified in the static ApplicationThemeHelper.ApplicationThemeName property:

csharp
private void Application_Exit(object sender, StartupEventArgs e) {
    ApplicationThemeHelper.SaveApplicationThemeName();
}
vb
Private Sub Application_Exit(ByVal sender As Object, ByVal e As StartupEventArgs)
    ApplicationThemeHelper.SaveApplicationThemeName()
End Sub

Call the static ApplicationThemeHelper.UpdateApplicationThemeName method to retrieve the theme name from the configuration file and apply it to your application:

csharp
private void Application_Startup(object sender, ExitEventArgs e) {
    ApplicationThemeHelper.UpdateApplicationThemeName();
}
vb
Private Sub Application_Startup(ByVal sender As Object, ByVal e As StartupEventArgs)
    ApplicationThemeHelper.UpdateApplicationThemeName()
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the RibbonGalleryItemThemePaletteSelectorBehavior 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-mvvm-behaviors-gallery-based-theme-palette-selector/CS/MainWindow.xaml#L23

xml
<dxmvvm:Interaction.Behaviors>
    <dxr:RibbonGalleryItemThemePaletteSelectorBehavior />
</dxmvvm:Interaction.Behaviors>

Inheritance

Show 13 items

Object DispatcherObject DependencyObject Freezable Animatable DevExpress.Mvvm.UI.Interactivity.AttachableObjectBase DevExpress.Mvvm.UI.Interactivity.Behavior DevExpress.Mvvm.UI.Interactivity.Behavior<RibbonGalleryBarItem> DevExpress.Xpf.Bars.ThemeSelectorBehavior<RibbonGalleryBarItem> DevExpress.Xpf.Bars.BarItemThemeSelectorBehavior<RibbonGalleryBarItem> DevExpress.Xpf.Bars.GalleryBarItemThemeSelectorBehavior<RibbonGalleryBarItem> RibbonGalleryItemThemeSelectorBehavior RibbonGalleryItemThemePaletteSelectorBehavior

See Also

RibbonGalleryItemThemePaletteSelectorBehavior Members

Behaviors

BarSubItemThemeSelectorBehavior

BarSplitItemThemeSelectorBehavior

GalleryThemeSelectorBehavior

RibbonGalleryItemThemePaletteSelectorBehavior

HamburgerSubMenuThemeSelectorBehavior

DevExpress.Xpf.Ribbon Namespace