Apply a StyleRepository

2 posts, 0 answers
  1. Jay
    Jay avatar
    4 posts
    Member since:
    Jan 2015

    Posted 16 Feb 2017 Link to this post

    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?


  2. Hristo
    Hristo avatar
    1504 posts

    Posted 17 Feb 2017 Link to this post

    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:

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

    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.
Back to Top