Change Theme Swatch at Runtime in C# Code

1 Answer 16 Views
General Discussions
Pedro
Top achievements
Rank 1
Pedro asked on 22 Jun 2025, 07:39 PM | edited on 22 Jun 2025, 07:40 PM

I configured the application to use customized Theme Colors (Swatches) following the link:

https://docs.telerik.com/devtools/maui/styling-and-themes/customize-the-theme#customizing-the-theme-colors-swatches

Next as requirement I should change the Theme Color (Swatch) at run-time based on the device, using C# code, the only link I found was:

https://docs.telerik.com/devtools/maui/knowledge-base/change-telerik-theme-runtime

But here the Telerik Theme is changed at run-time using only pre-defined Telerik Themes. So my question is: how can I change Default Theme Colors (Swatches) at run-time using C# code?

Thanks

1 Answer, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 24 Jun 2025, 03:14 PM

Hi Pedro,

To achieve the desired functionality in C#, you need to set TelerikThemeResources.AppTheme to the desired theme. After that, merge the custom swatch ResourceDictionary to apply the custom colors to the selected theme.

I’ve created a sample project that demonstrates how to switch from the TelerikPurple theme to the TelerikTurquoise theme, and then merge a custom swatch defined in CustomTelerikSwatch.xaml.

I hope this project will be of help. If you need further assistance, please reach out.

Regards, Elena Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
General Discussions
Asked by
Pedro
Top achievements
Rank 1
Answers by
Elena
Telerik team
Share this question
or