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

Overriding Theme for Specific Control After applying Customized Theme For Entire Application

5 Answers 575 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Surya
Top achievements
Rank 1
Surya asked on 08 Dec 2011, 02:11 PM
HI,

  i am using Customize Theme for my for entire  Windows Application . My Requirement for search textboxes i need Shaded Background Color As attached ShadedTextbox.png.

   After goggling i came to know that we can use 2 customize themes , one is for Entire Application and the other is for Search textboxes.
I tried http://www.telerik.com/community/forums/winforms/buttons/override-button-color-with-theme.aspx , but i unable to achieved.

Please look below sample code 
   Assembly lAssembly = Assembly.LoadFrom("RadTheme.dll");
            ThemeResolutionService.LoadPackageResource(lAssembly, "RadTheme.Theme.FenixTheme.tssp");
            ThemeResolutionService.LoadPackageResource(lAssembly, "RadTheme.Theme.FenixThemeTwo.tssp");


            //ThemeResolutionService.LoadPackageResource("RadThemeExample.Themes.FenixTheme.tssp");
            //ThemeResolutionService.LoadPackageResource("RadThemeExample.Themes.FenixThemeTwo.tssp");


            ThemeResolutionService.ApplicationThemeName = "FenixTheme";
            this.radTextBox1.ThemeName = "FenixThemeTwo";


Please Find Attached Image SampleApp.png.

  


5 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 12 Dec 2011, 06:07 PM
Hello Surya,

Thank you for writing.

If you want to use two themes at the same time you cannot use ThemeResolutionService.ApplicationThemeName, because after you set this property the ThemeName property of each control is ignored and will not affect its theme. To use two themes you have to set the theme individually to each control using the ThemeName property. One thing that will help you is using ThemeResolutionService.ApplyThemeToControlTree and passing as parameters a form and the theme name you want to set to most of the controls. After that you can set the ThemeName property for the controls you want with a different theme to the desired theme name. One draw back of this method is that you will have to set the theme in all forms separately.

I noticed that I have made an error in the forum thread you have followed by suggesting ApplicationThemeName at the bottom of the thread. Actually, I meant to write ApplyThemeToControlThree.
Now this error is addressed. 

I hope this will help. If you have further questions, I would be glad to assist.

Regards,
Ivan Petrov
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

0
Jim
Top achievements
Rank 1
answered on 12 Apr 2018, 11:04 AM

Following this up 7 years later, it turns out that

>If you want to use two themes at the same time you cannot use ThemeResolutionService.ApplicationThemeName, because after you set this property the ThemeName property of each control is ignored and will not affect its theme.

is no longer the case. You can override the them of a control even if you have used ThemeResolutionService.ApplicationThemeName by calling:

            myControl.ElementTree.EnableApplicationThemeName = false;
            myControl.ThemeName = "Office2013Dark";

0
Hristo
Telerik team
answered on 13 Apr 2018, 12:53 PM
Hi Jim,

Thank you for updating the thread. Indeed the required behavior is now possible: https://docs.telerik.com/devtools/winforms/themes/using-a-default-theme-for-the-entire-application#enabledisable-the-globally-set-theme-for-a-specific-control
ThemeResolutionService.ApplicationThemeName = "Office2010Blue";
radGridView1.ElementTree.EnableApplicationThemeName = false;
radGridView1.ThemeName = "Office2010Silver";

Regards,
Hristo
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Ali
Top achievements
Rank 1
answered on 14 Sep 2019, 10:56 AM
Hello,
Implementing the code as below, I have faced another problem:
In objects having a child object, like RadDropdownButton or RadCheckedDropDownList,  theme of the parent object will be changed to the new theme (Office2010Silver) but dropdown-elements still remain in the main-theme (Office2010Blue).
Is there any solution to make them inherited from the parent object's theme?

ThemeResolutionService.ApplicationThemeName = "Office2010Blue";
radGridView1.ElementTree.EnableApplicationThemeName = false;
radGridView1.ThemeName = "Office2010Silver";
0
Dimitar
Telerik team
answered on 16 Sep 2019, 10:22 AM

Hello Ali,

The popup is a separate control where you need to set the EnableApplicationThemeName property as well:

radDropDownButton1.ElementTree.EnableApplicationThemeName = false;
radDropDownButton1.ThemeName = "Office2010Silver";
var popup  = radDropDownButton1.DropDownButtonElement.DropDownMenu.ElementTree.Control as RadControl;
popup.ElementTree.EnableApplicationThemeName = false;

radCheckedDropDownList1.ElementTree.EnableApplicationThemeName = false;
radCheckedDropDownList1.ThemeName = "Office2010Silver";
var popup1 = radCheckedDropDownList1.CheckedDropDownListElement.Popup as RadControl;
popup1.ElementTree.EnableApplicationThemeName = false;

I hope this helps. Should you have any other questions, do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Themes and Visual Style Builder
Asked by
Surya
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Jim
Top achievements
Rank 1
Hristo
Telerik team
Ali
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or