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

Apply a StyleRepository

1 Answer 99 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 16 Feb 2017, 08:35 PM

Is there any way to apply a StyleRepository object to a control? I know I can do something like:

         Theme currenTheme = ThemeRepository.FindTheme(ThemeResolutionService.ApplicationThemeName);
         StyleRepository repositoryFromTheme = currenTheme.FindRepository("DisabledForeColor");
         PropertySetting styleForeColor = repositoryFromTheme.FindSetting("ForeColor");
         Color colorToSet = (Color)styleForeColor.Value;
         myTextBox.Forecolor = colorToSet;

However, if I have multiple properties to set (say, multiple colors and maybe some transparency or a background image or something), this can get a bit tedious and it lacks flexibility. So, what I'd like to do is just take the StyleRepository object and apply it directly to the control. Alternately, I'd be fine with looping through the settings collection and applying each of those individually so long as I didn't have to hard code the names of the PropertySettings into my code. Something like:

         foreach (PropertySetting currentPropertySetting in repositoryObjectFromTheme.Settings)
         {
            genericRadControl.SOMETHING = currentPropertySetting;
         }

would work for me fine as well.

Any suggestions?

 

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 17 Feb 2017, 03:31 PM
Hello Jay,

Thank you for writing.

StyleRepositories can be applied on particular elements. You can either access a particular setting by its name or you can iterate all of the settings and based on their type execute your custom logic: 
this.radRibbonBar1.ThemeName = "Office2013Light";
Theme theme = ThemeRepository.FindTheme(this.radRibbonBar1.ThemeName);
foreach (StyleRepository repo in theme.Repositories)
{
    foreach (PropertySetting setting in repo.Settings)
    {
        //...
    }
}

In case you need to change the overall look of all controls from a particular theme you can use our Color Blending support: http://docs.telerik.com/devtools/winforms/tools/visual-style-builder/working-with-visual-style-builder/color-blending.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Themes and Visual Style Builder
Asked by
Jay
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or