title | page_title | description | slug | tags | published | position |
---|---|---|---|---|---|---|
Styles and Templates |
Styles and Templates |
This article explains how to modify the apperance of the RadTabbedWindow control. |
radtabbedwindow-styles-and-templates |
getting,started |
true |
4 |
RadTabbedWindow allows you to easily modify its appearance by providing some useful properties.
Via the AddButtonStyle property, you can control the appearance of the button which is used to add new tabs to the window.
{{region xaml-radtabbedwindow-styles-and-templates_0}} telerik:RadTabbedWindow.AddButtonStyle <Style TargetType="telerik:RadButton" BasedOn="{StaticResource AddItemsButtonStyle}"> </Style> </telerik:RadTabbedWindow.AddButtonStyle> {{endregion}}
importantIf you are using the default Office_Black theme (you have not merged a theme assembly) or you've set a different theme with the [StyleManager]({%slug styling-apperance-implicit-styles-overview%}), you should copy the AddItemsButtonStyle and all the referenced resources from the Telerik.Windows.Controls.Navigation.xaml file into your project.
You can use the ItemContainerStyle property to style the individual RadTabItem elements.
{{region xaml-radtabbedwindow-styles-and-templates_1}} telerik:RadTabbedWindow.ItemContainerStyle <Style TargetType="telerik:RadTabItem" BasedOn="{StaticResource RadTabbedWindowTabItemStyle}"> </Style> </telerik:RadTabbedWindow.ItemContainerStyle> {{endregion}}
importantIf you are using the default Office_Black theme (you have not merged a theme assembly) or you've set a different theme with the [StyleManager]({%slug styling-apperance-implicit-styles-overview%}), you should copy the RadTabbedWindowTabItemStyle and all the referenced resources from the Telerik.Windows.Controls.Navigation.xaml file into your project.
You can also define a StyleSelector and conditionally style the tab items via the ItemContainerStyleSelector property.
{{region cs-radtabbedwindow-styles-and-templates_2}} public class MyTabItemStyleSelector : StyleSelector { public Style ProgressStyle { get; set; } public Style NormalStyle { get; set; }
public override Style SelectStyle(object item, DependencyObject container)
{
var tab = item as Tab;
if (tab.Header.Contains("Progress"))
{
return this.ProgressStyle;
}
return this.NormalStyle;
}
}
{{endregion}}
{{region vb-radtabbedwindow-styles-and-templates_3}} Public Class MyTabItemStyleSelector Inherits StyleSelector
Public Property ProgressStyle() As Style
Public Property NormalStyle() As Style
Public Overrides Function SelectStyle(ByVal item As Object, ByVal container As DependencyObject) As Style
Dim tab = TryCast(item, Tab)
If tab.Header.Contains("Progress") Then
Return Me.ProgressStyle
End If
Return Me.NormalStyle
End Function
End Class
{{endregion}}
{{region xaml-radtabbedwindow-styles-and-templates_4}} <telerik:RadTabbedWindow ... ItemContainerStyle="{x:Null}"> telerik:RadTabbedWindow.ItemContainerStyleSelector local:MyTabItemStyleSelector local:MyTabItemStyleSelector.ProgressStyle <Style TargetType="telerik:RadTabItem" BasedOn="{StaticResource RadTabbedWindowTabItemStyle}"> </Style> </local:MyTabItemStyleSelector.ProgressStyle> local:MyTabItemStyleSelector.NormalStyle <Style TargetType="telerik:RadTabItem" BasedOn="{StaticResource RadTabbedWindowTabItemStyle}" /> </local:MyTabItemStyleSelector.NormalStyle> </local:MyTabItemStyleSelector> </telerik:RadTabbedWindow.ItemContainerStyleSelector> </telerik:RadTabbedWindow> {{endregion}}
importantPlease note that to use the ItemContainerStyleSelector property, you need to clear the ItemContainerStyle by setting it to null.
When binding your RadTabbedWindow to a collection, you are able to configure the visualization of the data and the appearance of the tab items via the ItemTemplate and the ItemTemplateSelector properties.
{{region xaml-radtabbedwindow-styles-and-templates_5}} telerik:RadTabbedWindow.ItemTemplate </telerik:RadTabbedWindow.ItemTemplate> {{endregion}}
If you wish to return different templates for the tab items, you can use the ItemTemplateSelector property and pass a custom DataTemplateSelector to it.
Similarly, in a data-binding scenario you can control the appearance of the tabs' content via the ContentTemplate and the ContentTemplateSelector properties.
{{region xaml-radtabbedwindow-styles-and-templates_6}} telerik:RadTabbedWindow.ContentTemplate </telerik:RadTabbedWindow.ContentTemplate> {{endregion}}
If you wish to return different templates for the tab items' content, you can use the ContentTemplateSelector property and pass a custom DataTemplateSelector to it.
- [Key Properties]({%slug radtabbedwindow-key-properties%})
- [Events]({%slug radtabbedwindow-events%})