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

Mixing VisualStudio2012Light with custom Theme

1 Answer 86 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Leandro
Top achievements
Rank 1
Leandro asked on 02 Dec 2016, 06:19 PM

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

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 05 Dec 2016, 01:53 PM
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.
Tags
Themes and Visual Style Builder
Asked by
Leandro
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or