This example demonstrates OneNote style Tab Control. The sample demonstrates also how to style UI elements through code. To achieve this use Selectors and Behaviors.
FillPrimitive fill = (FillPrimitive)new ClassSelector("TabFill").GetSelectedElements(item)[0]; fill.BackColor2 = color;
The ClassSelectror object if responsible for traversing the UI tree and finding the corresponding element(s) within. The class names (RadElement.Class property) of different elements in the UI hierarchy can be browsed, using the RadControlSpy tool.
item.AddBehavior(new TabItemSelectedBehavior(this.radTabStrip1, color)); ... public class TabItemSelectedBehavior : PropertyChangeBehavior { public override void OnPropertyChange(RadElement element, RadPropertyChangedEventArgs e) { if ((bool)e.NewValue == true) { ClassSelector selector = new ClassSelector("TabBaseFill"); FillPrimitive fill = (FillPrimitive)selector.GetSelectedElements(this.tabStrip.RootElement)[0]; fill.BackColor = backColor; } } }
The PropertyChangeBehavior class is used add custom functionality when a RadProperty is changed. To add behavior to any RadItem use the AddBehavior function. Inherit your class from PropertyChangeBehavior and override the OnPropertyChange function.