Custom control template and using various themes

3 posts, 1 answers
  1. Vahid
    Vahid avatar
    4 posts
    Member since:
    Sep 2007

    Posted 13 Dec 2011 Link to this post

    I'm trying to customize the combobox template, so it contains two "refresh" and "add new" buttons in it.
    It's done by using Blend, and extracting default template, and then editing it.
    But the problem is, when you extract the template, it extract the styles off Office_Black theme (which is default), and the theme gets hard-coded in the template, so when the user tries to change the theme of the application at run time (for example changing to Metro), the combo box stay in Office_Black!

    how can i customize the control, but still change the theme at run time?

    Thanks in advance
  2. Answer
    Dani avatar
    848 posts

    Posted 16 Dec 2011 Link to this post

    Hello Vahid,

    Any change or customization to the style or template of RadComboBox will hard-code resources, regardless of whether it is for Office Black or for another theme. This is inevitable.

    If you wish to use more than one theme in your application and to keep changing themes at runtime, the approach you should use is not elegant and will produce a large amount of resources. 

    First off, you have to apply your customizations to the RadComboBox style for each Telerik theme. Then, you can either: switch resource dictionaries at runtime, depending on the chosen theme, or you can: create a custom theme corresponding to each Telerik theme and apply it to the RadComboBox control depending on the switched application theme.

    As explained, this is not recommended, so it is better to  have a custom RadComboBox with a single theme if this fits in your scenario.

    In any case, you will need to also recreate the layout in order for your controls to pick up the new theme.

    I hope this helps.

    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. DevCraft banner
  4. Vahid
    Vahid avatar
    4 posts
    Member since:
    Sep 2007

    Posted 16 Dec 2011 Link to this post

    Dani, thanks for your reply!
Back to Top