This is a migrated thread and some comments may be shown as answers.

How to extract Theme settings when using XAML.DLL / StyleManager?

1 Answer 149 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rob A.
Top achievements
Rank 2
Iron
Iron
Veteran
Rob A. asked on 22 Jan 2021, 06:02 PM

Is there a way to extract active theme settings from the StyleManager?

Cheers, Rob.

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 27 Jan 2021, 01:11 PM

Hi Rob,

I assume that by settings you mean the palette colors, font sizes, opacities, and other theme-related values. If that is the case, you can do so by determining the current theme through the StyleManager.ApplicationTheme property and accessing its respective Palette property:

            var theme = StyleManager.ApplicationTheme;
            if (theme is MaterialTheme)
            {
                var materialPalette = MaterialPalette.Palette;
                var accentColor = materialPalette.AccentNormalColor;
                var mainColor = materialPalette.MainColor;
                // ...
            }
            else if (theme is FluentTheme)
            {
                var fluentPalette = FluentPalette.Palette;
                var accentColor = fluentPalette.AccentColor;
                var mainColor = fluentPalette.MainColor;
                // ...
            }
            // ...
Please note that this is only possible for the themes which support palettes such as Office2019, Office2016, Material, Fluent etc.

You can also have a look at our Color Theme Generator application which allows you to experiment with the theme colors and immediately see the results.

Please let me know if this is what you have in mind and whether you found this helpful.

Regards,
Dilyan Traykov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
Rob A.
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Dilyan Traykov
Telerik team
Share this question
or