Override Button Color with Theme

7 posts, 0 answers
  1. Nigel
    Nigel avatar
    2 posts
    Member since:
    Jun 2010

    Posted 15 Jun 2010 Link to this post

    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
  2. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 18 Jun 2010 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mark K.
    Mark K. avatar
    18 posts
    Member since:
    Oct 2008

    Posted 18 Jan 2011 Link to this post

    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
  5. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 21 Jan 2011 Link to this post

    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.
  6. Mohammed
    Mohammed avatar
    19 posts
    Member since:
    Jan 2016

    Posted 03 Mar in reply to Ivan Petrov Link to this post

    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

  7. Mohammed
    Mohammed avatar
    19 posts
    Member since:
    Jan 2016

    Posted 03 Mar in reply to Mark K. Link to this post

    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

     

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

  8. Dess
    Admin
    Dess avatar
    1607 posts

    Posted 04 Mar Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready