Different theme applied to different components of the same control

3 Answers 32 Views
DateTimePicker
ASM
Top achievements
Rank 1
Iron
Iron
ASM asked on 08 Aug 2023, 05:59 AM

Hello,

I was wondering how to do the following on a DateTimePicker, if it is possible at all: apply one theme to the main control and another to its calendar.

Something like this:

RadDateTimePicker1.ThemeName = A


Dim calendarBehavior As RadDateTimePickerCalendar = TryCast(RadDateTimePicker1.DateTimePickerElement.GetCurrentBehavior(), RadDateTimePickerCalendar)
Dim calendar As RadCalendar = TryCast(calendarBehavior.Calendar, RadCalendar)

calendar.ThemeName = B
Thank you

3 Answers, 1 is accepted

Sort by
0
tar
Top achievements
Rank 2
Iron
Iron
Iron
answered on 08 Aug 2023, 11:39 PM

By using the RadThemeManager, load your themes files into it and after that you can set different themes to your Rad controls via their ThemeName property.

Check this video from 7:15 onwards: Styling Basics with Visual Style Builder for WinForms

0
ASM
Top achievements
Rank 1
Iron
Iron
answered on 09 Aug 2023, 06:22 AM
Thanks for the answer, tar, but I don't think it solves what I was asking.

I want to apply different themes to the same control. Specifically I'm thinking about the DateTimePicker, I want to apply one theme to the edit box and a different theme to the popup with the calendar.

At the moment I can only think of doing this by creating a custom theme that merges the two I want to use, but I would prefer to avoid doing that.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 10 Aug 2023, 09:04 AM

Hello, Armand,

  

The theme that is set through ApplicationThemeName property of ThemeResolutionService is with higher priority than the locally set themes to controls/dialogs. However, you can disable the globally set theme to a specific control and apply a different theme. You can set the control's ElementTree.EnableApplicationThemeName property to false and set the control's ThemeName to the desired theme explicitly for each control:

https://docs.telerik.com/devtools/winforms/styling-and-appearance/using-a-default-theme-for-the-entire-application#enabledisable-the-globally-set-theme-for-a-specific-control

I have prepared a sample code snippet for your reference:

            ThemeResolutionService.ApplicationThemeName = "CrystalDark";

            RadDateTimePickerCalendar calendarBehavior = this.radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;
            RadCalendar calendar = calendarBehavior.Calendar as RadCalendar;


            calendar.ElementTree.EnableApplicationThemeName = false;
            calendar.ThemeName = "Crystal";

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
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
DateTimePicker
Asked by
ASM
Top achievements
Rank 1
Iron
Iron
Answers by
tar
Top achievements
Rank 2
Iron
Iron
Iron
ASM
Top achievements
Rank 1
Iron
Iron
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or