Ticket T1282459
Visible to All Users

Styling from devexpress theme assets - how to pull them?

created 6 months ago

As I develop our enterprise suite of application, we want to do something like:

Create a button that clears everything out of a list. Its text is a FontAwesome symbol. However, we want the color to be the SAME color that we have when you see the circle-x that can be embedded inside a combobox.

Working with devex in the past, here's an example of somethign that works:

Code
<dxi:ThemeResource x:Key="ColorRemove" ThemeKey="{dxt:ThemedWindowThemeKey ResourceKey=WindowInactiveBorderBrush}" />

I can't figure out what other options I have besides ThemedWindowThemeKey. If I search (in xaml autocomplete) for brush in ThemedWindowThemeKey, I get these options for brushes:

Clipboard-File-1.png

Are there more anywhere else? If so, how do I access them?

Thanks!

Answers approved by DevExpress Support

created 6 months ago

Hello Greg,

In one of the previous threads, I shared the following link to our documentation: Modify Theme Resources. In that help topic, we mention how to utilize the ThemeResource extension: Use a Theme’s Dynamic Resources. In this manner, you can declare any theme dependent resources - not just brushes.

Our controls utilize the Office2019Colorful theme by default. You can use the following path to find its source files:

Code
\DevExpress 24.2\Components\Sources\XPF\DevExpress.Xpf.Themes\Office2019Colorful

To find the required resource, whether it's a brush or a template, you can utilize our Theme Designer: WPF Theme Designer.

Alternatively, if you know the element's type, name or resource key, you can search across theme resources directly. Personally, I utilize Notepad++ for this task. For example, ThemedWindowThemeKey ResourceKey=WindowInactiveBorderBrush is a relatively unique string:

Clipboard-File-1.png
Clipboard-File-2.png
Clipboard-File-3.png

Note that we do not have a specific source file that contains all theme brushes.

Please let me know if you have further questions.

See also: Palettes

Regards,
Alexander

    Comments (2)

      Thanks, the find-in-files is exactly what I was looking for.

      As a followup, if I change my theme while my app is running, will this (using the xaml styles to pull elements from the theme) switch over and return the correct 'new' color? We are currently using vs2019 light\dark as our base, and modifying the elements with styles.

      C#
      public static void ApplyTheme(ThemeMode themeMode = ThemeMode.Light) { if (themeMode == ThemeMode.Dark) { // Set the theme, this can be stored in a configuration file ApplicationThemeHelper.ApplicationThemeName = Theme.VS2019DarkName; } else { // Set the theme, this can be stored in a configuration file ApplicationThemeHelper.ApplicationThemeName = Theme.VS2019LightName; } CurrentTheme = themeMode; }
      Alexander D (DevExpress Support) 6 months ago

        I am happy to hear that this helped, Greg.

        The ThemeResource extension does indeed retrieve resources dynamically as long as they are not overridden by a theme independent resource at the application level. See: Apply Modified Theme Resources To Your Application.

        Please note that resources are not universal across all themes. While VS2019Dark and VS2019Light have a similar structure, Win11 themes or older themes (e.g., DXStyle) will have a different set of keys.

        If you have further questions, please let me know.

        Regards,
        Alexander

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.