We keep a close track of the latest trends and we know how popular HTML5 and CSS are these days. That is why while implementeing our new theme engine, which we presented in our previous blog, we added a small, but powerful styling feature and in this blog we want to tell you more about it.
Until now there were two ways to create new themes for RadControls. The first one is to use the Visual Style Builder tool (http://www.telerik.com/products/winforms/tools.aspx) and to create or modify an existing theme. The other way is a bit tricky as you should edit an XML file. We know that sometimes these XML files can be huge. That’s why, we added a third option in our latest release. Now you can create your own theme utilizing a simple CSS-like syntax.
We are eager to show you the power of this feature. Let’s start with something simple, the following code changes the background for the pie segment named Apple to red in our new chart control:
Of course, this is not a true CSS. Our TPF elements are quite different from div and span tags. They have different properties and different visualization. Every stylable property can be changed by using the new syntax. Moreover, the new syntax allows creating exciting animations. For example:
We use the code above to apply the nice exploding animation of the Pie Chart example in our Demo application. Check our new examples to see more impressive animations.
The created theme can be applied with a single line of code; one should just call one of the ReadCSS or ReadCSSText methods and add the newly created theme to the repository:
Theme theme = Theme.ReadCSSText (cssFormattedTextString);
Of course, if you do not want to play with the new CSS-like syntax, you can do the same in the old-fashioned manner:
Theme theme =
StyleGroup styleGroup =
PropertySettingGroup settingGroup =
PropertySetting setting =
setting.EndValue = 1;
setting.AnimatedSetting.EndValue = 1;
setting.AnimatedSetting.MaxValue = 1.02;
setting.AnimatedSetting.NumFrames = 30;
setting.AnimatedSetting.Interval = 30;
setting.AnimatedSetting.ApplyEasingType = RadEasingType.OutElastic;
setting.AnimatedSetting.RandomDelay = 200;
Have fun exploring the new theming features!