Reading values from Theme

2 posts, 0 answers
  1. David
    David avatar
    1 posts
    Member since:
    Jun 2012

    Posted 22 Jun 2012 Link to this post

    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" />

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

  2. Jack
    Jack avatar
    2335 posts

    Posted 26 Jun 2012 Link to this post

    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");

    If you have further questions, do not hesitate to write us.
    All the best,
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. DevCraft R3 2016 release webinar banner
Back to Top