Mixing VisualStudio2012Light with custom Theme

2 posts, 0 answers
  1. Leandro
    Leandro avatar
    3 posts
    Member since:
    Jul 2015

    Posted 02 Dec 2016 Link to this post

    Hi

    What I'm trying to do is to use VisualStudio2012Light theme on my entire application and on my main form trying to use my custom theme on some controls. But my custom theme is not applying on the controls

    The Code:

    On Program.Main() 

      using (var TemaGeral = new Telerik.WinControls.Themes.VisualStudio2012LightTheme())
                {
                    TemaGeral.DeserializeTheme();
                    ThemeResolutionService.ApplicationThemeName = TemaGeral.ThemeName;
                }

    On MyForm.Constructor()

           public NovoMenu()
            {
                InitializeComponent();
                
                using (var tema = new Temas.Telerik.NossoERPVisualStudio2012LightTheme())
                {
                    tema.Load();
                    tema.DeserializeTheme();
                    ThemeResolutionService.ApplyThemeToControlTree(pnMenu, tema.ThemeName);
                    this.ThemeName = tema.ThemeName;
                }

            }

     

    My Custom Theme class

     

     public class NossoERPVisualStudio2012LightTheme : RadThemeComponentBase
        {
            static bool loaded;
            public NossoERPVisualStudio2012LightTheme()
            {
                ThemeRepository.RegisterTheme(this);
            }
            static NossoERPVisualStudio2012LightTheme()
            {

            }

            public override void Load()
            {
                if (!loaded || this.IsDesignMode)
                {
                    loaded = true;
                    Assembly resource = typeof(NossoERPVisualStudio2012LightTheme).Assembly;
                    this.LoadResource(resource, "Nosso.Temas.Telerik.NossoERPVisualStudio2012Light.tssp");
                }
            }
            public override string ThemeName
            {
                get
                {
                    return "NossoERPVisualStudio2012Light";
                }
            }
        }

     

    Is that possible?

    My theme code is working i've tested it using on my entire application, and its ok.

     

    Sorry for bad english

     

     

     

  2. Hristo
    Admin
    Hristo avatar
    1028 posts

    Posted 05 Dec 2016 Link to this post

    Hi Leandro,

    Thank you for writing.

    Please note that the static ApplicationThemeName property has the highest priority when setting the theme. Calling the ApplyThemeToControlTree method with your theme will have no effect because it will eventually set the ThemeName property of the specified controls and in this scenario, it will be overridden by the ApplicationThemeName setting: http://docs.telerik.com/devtools/winforms/themes/using-a-default-theme-for-the-entire-application.

    In order to achieve your task, you can set themes individually not using the global ApplicationThemeName  property.

    I hope this helps. Please let me know if you need further assistance.

    Regards,
    Hristo Merdjanov
    Telerik by Progress
    Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
Back to Top