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

Override Button Color with Theme

6 Answers 555 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Nigel
Top achievements
Rank 1
Nigel asked on 15 Jun 2010, 03:16 PM
Hi:

I applied an application wide theme but need to override the background color on 2 buttons.  What's the best way to do this while still retaining the "look" of the theme.  The theme currently in use is "Breeze" but two buttons out of the dozens in the entire application need to have Green and Red backgrounds.  I tried simply turning off themeing in those two buttons but the resulting "look" contrasted too greatly with the breeze theme. 

So, i guess i'm asking how to override the background color on these two buttons while still maintaining the overall feel of the breeze theme.

Thanks.

-eLindy

6 Answers, 1 is accepted

Sort by
0
Boryana
Telerik team
answered on 18 Jun 2010, 02:52 PM
Hi Nigel,

Thank you for contacting us.

You can easily achieve the desired appearance. The best way to apply a theme across your whole application (on form basis) is to use ThemeResolutionService. Further, you might apply a different theme to a particular control through setting the ThemeName property of this control. Considering your example the BreezeExtended theme will be applied to all controls in your application except from the two RadButtons. The following code snippet illustrates this approach:
private void Form1_Load(object sender, EventArgs e)
{
    ThemeResolutionService.ApplyThemeToControlTree(this, "BreezeExtended");
    this.radButton1.ThemeName = "BreezeExtendedRed";
    this.radButton2.ThemeName = "BreezeExtendedGreen";
}

Please note that it is very important for your application to use the BreezeExtended theme instead of the Breeze theme. Once you switch to BreezeExtended you will be able to load this theme in our Visual Style Builder tool and modify the ButtonFill (FillPrimitive) of the RadButton. With only a few clicks you can modify the BreezeExtended theme and create two versions - one with green background and the other with red.  For more information about how to use the Visual Style Builder please refer to the following tutorial and video materials. Further, you can apply the custom themes to the two buttons using the approach described above.

I hope you find this helpful. Please let me know if you experience any difficulties.

All the best,
Boryana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mark K.
Top achievements
Rank 1
answered on 18 Jan 2011, 09:17 PM
How do I get two different themes for the same control in my theme package?  I do not find anything in your documentation that tells how to do this.

I have some RadToggleButtons in my application.  I want some of them to have one set of colors (for the various states) and other ones to have a second set of colors.  How do I set up a second instance of RadToggleButton in Visual Style Builder?

Thanks,

Mark
0
Ivan Petrov
Telerik team
answered on 21 Jan 2011, 08:47 AM
Hello Nigel,

Thank you for writing.

Currently, the way to achieve this is to have two different theme packages, one complete theme package and one just for the control(s) you need a second theme for. You will need to export the build-in themes if you are using one of them and edit the controls you want or if you are using a custom theme you can directly edit it. When you are saving the theme, you need to give it an unique (to the other themes you have) name. After you have two themes the best approach is to add them to you project resources and set their build action to Embedded Resource. When you have your themes in your project you can load them into you application using the following  code :
ThemeResolutionService.LoadPackageResource("ProjectName.FolderName.Theme1FileName.Extention");
ThemeResolutionService.LoadPackageResource("ProjectName.FolderName.Theme2FileName.Extention");
ThemeResolutionService.ApplyThemeToControlTree(this, "Theme1FileName");
this.radToggleButton1.ThemeName = "Theme2FileName";
this.radToggleButton2.ThemeName = "Theme2FileName";

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

Best wishes,
Ivan Petrov
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
0
Mohammed
Top achievements
Rank 1
answered on 03 Mar 2016, 04:39 PM

Hi,

This is exactly what I need. Just one question though, is it possible to use one theme package and apply two distinct themes to two buttons? I'm asking this in the scenario that we would have multiple themes and switching between them would change the themes on buttons. If we did this using your solution we would have double the amount of theme files to contend with whereas I am asking if two buttons could be set with two different xml themes in the same theme package. I hope this makes sense. I have read your solution and it is what I will use but I thought I'd ask in case this has been made possible in the 5 years since it has been posted.

 

Thank you

Mohammed

0
Mohammed
Top achievements
Rank 1
answered on 03 Mar 2016, 04:43 PM

[quote]Mark K. said:How do I get two different themes for the same control in my theme package?  I do not find anything in your documentation that tells how to do this.

I have some RadToggleButtons in my application.  I want some of them to have one set of colors (for the various states) and other ones to have a second set of colors.  How do I set up a second instance of RadToggleButton in Visual Style Builder?

Thanks,

Mark
[/quote]

 

Sorry, exactly what Mark K is saying, is the functionality I would like to achieve.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 Mar 2016, 02:46 PM
Hello Mohammed,

Thank you for writing.

In order to achieve two different themes for one and the same control, you should create two different themes in Visual Style Builder as it is explained by my colleague, Ivan Petrov. Thus, by setting the ThemeName property of the control you can change the look.

You can read more details about using the VisualStyleBuilder here:
1.     Loading predefined themes
2.     Working with Repository Items
3.     Saving and Loading Theme Files
4.     Loading Themes from an External File
5.     Loading Themes from a Resource
6.     Applying Theme to a Control
7.     http://tv.telerik.com/watch/winforms/visualstylebuilder/whats-new-visual-style-builder-q1-2010

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Nigel
Top achievements
Rank 1
Answers by
Boryana
Telerik team
Mark K.
Top achievements
Rank 1
Ivan Petrov
Telerik team
Mohammed
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or