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

Reading values from Theme

1 Answer 90 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 22 Jun 2012, 08:57 PM
I'd like to programmaticly read a value from a theme. I've created the following item:

       <Telerik.WinControls.Styles.XmlRepositoryItem ItemType="Gradient" DisplayName="MyNormalControlColor" Key="MyNormalControlColor" Capacity="4">
        <XmlPropertySetting Property="Telerik.WinControls.VisualElement.BackColor" Value="0, 0, 0" />
        <XmlPropertySetting Property="Telerik.WinControls.Primitives.FillPrimitive.GradientStyle" Value="Solid" />
        <XmlPropertySetting Property="Telerik.WinControls.Primitives.FillPrimitive.NumberOfColors" Value="1" />
      </Telerik.WinControls.Styles.XmlRepositoryItem>

If I'm in my code (C#), any idea how to read that value out of the theme to use it when drawing?


Thanks.

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 26 Jun 2012, 03:21 PM
Hello David,

You can do this by using the new theme API introduced in our latest release - Q2 2012. Here is a sample:
Theme theme = ThemeRepository.FindTheme("MyTheme");
if (theme != null)
{
    StyleRepository repository = theme.FindRepository("MyNormalControlColor");
    foreach (PropertySetting setting in repository.Settings)
    {
        Console.WriteLine("{0}: {1};", setting.Name, setting.Value);
    }
}

In the code above we assume that the theme is already loaded in memory. If this is not the case you can load the theme by using the following code:
Theme theme = Theme.ReadTSSP(@"c:\MyTheme.tssp");
ThemeRepository.Add(theme);

If you have further questions, do not hesitate to write us.
 
All the best,
Jack
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
Themes and Visual Style Builder
Asked by
David
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or