The ThemeResource extension allows you to load a resource from a currently applied DevExpress theme without specifying the theme name in xaml and reload the resource if a theme is changed. You can reference the resource in xaml:
XAML<Border Background="{dxi:ThemeResource {dxt:FloatingContainerThemeKey ResourceKey=FloatingContainerBackground}}" />
Files to Look At
Documentation
- Customize Themes
- Knowledge Base Article: How to implement the ThemeMananger theme support in custom controls
More Examples
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
XAML<Window x:Class="T207471.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxi="http://schemas.devexpress.com/winfx/2008/xaml/core/internal"
xmlns:dxt="http://schemas.devexpress.com/winfx/2008/xaml/core/themekeys"
dx:ThemeManager.ThemeName="{Binding EditValue, ElementName=combo}"
Title="MainWindow" Height="350" Width="525">
<DockPanel>
<dxe:ComboBoxEdit Name="combo" ItemsSource="{x:Static dx:Theme.Themes}" EditValue="{x:Static dx:Theme.DefaultThemeName}"
DisplayMember="Name" Margin="5" ValueMember="Name" DockPanel.Dock="Top" Width="200" />
<TextBlock Text="The border below uses a theme-specific background:" FontSize="17" DockPanel.Dock="Top" HorizontalAlignment="Center" />
<Border Margin="30" Background="{dxi:ThemeResource {dxt:FloatingContainerThemeKey ResourceKey=FloatingContainerBackground}}" />
</DockPanel>
</Window>
C#using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace T207471 {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
}
}