Telerik RadRibbonBar provides a simple and consistent way for building interfaces similar to the RibbonBar used in Microsoft Office. The RadRibbonBar consists of various elements, one of which is the Ribbon Tab. This topic discusses concepts fundamental to the Ribbon Tab at first and then goes into the usage of the RadRibbonTab class and its features.
Tip |
|---|
|
Before proceeding with this tutorial, it is recommended to get familiar with the
Visual Structure of the RadRibbonBar control.
|
Ribbon Tab - Fundamentals
The RadRibbonBar helps end-users to quickly find the tools and options they need in order to complete a task. Tools and options are organized in logical groups that are collected together under specific tabs. Or in other words - the Ribbon Tab lets you categorize the commands to be displayed for the end-users.
Note |
|---|
The class that represents the ribbon tab is Telerik.Windows.Controls.RadRibbonTab.
|
The RadRibbonTab is a HeaderdItemsControl. Which means that the RadRibbonTab contains a heading (or title) and multiple items.
Check out the rest of this topic, which is entirely dedicated to the RadRibbonTab.
Adding Tab Items
When you are designing a new RadRibbonBar, one of your first tasks will be to add tabs. In order to add RibbonTabs to your RadRibbonBar control, you need to populate the RadRibbonBar's Items collection.
The next example demonstrates how to add several RadRibbonTabs to your ribbon and how to set their Header property.
CopyXAML
<telerik:RadRibbonBar x:Name="radRibbonBar">
<telerik:RadRibbonTab Header="Home" />
<telerik:RadRibbonTab Header="Insert" />
<telerik:RadRibbonTab Header="Page Layout" />
<telerik:RadRibbonTab Header="References" />
<telerik:RadRibbonTab Header="Mailings" />
<telerik:RadRibbonTab Header="Review" />
<telerik:RadRibbonTab Header="View" />
</telerik:RadRibbonBar> Tip |
|---|
|
Use the RadRibbonTab's Header property, when you want to set the Title for the RibbonTab.
|
Working with Selection
For more information, please take a look at the Selection topic.
Changing the Default Selected Tab
The first item in the Items collection is the default selected RibbonTab. However, you have the ability to change the default selected RibbonTab, by setting the RadRibbonTab's IsSelected property.
The example below sets the IsSelected property to True of the "References" RibbonTab.
CopyXAML
<telerik:RadRibbonBar x:Name="radRibbonBar">
<telerik:RadRibbonTab Header="Home" />
<telerik:RadRibbonTab Header="Insert" />
<telerik:RadRibbonTab Header="Page Layout" />
<telerik:RadRibbonTab Header="References" IsSelected="True" />
<telerik:RadRibbonTab Header="Mailings" />
<telerik:RadRibbonTab Header="Review" />
<telerik:RadRibbonTab Header="View" />
</telerik:RadRibbonBar> Accessing the Selected Tab Run-Time
Sometimes you may want to access the currently selected tab run-time. In this case, you should use the RadRibbonBar's SelectedTab property.
CopyC#
RadRibbonTab currentlySelectedTab = radRibbonBar.SelectedTab;
CopyVB.NET
Dim currentlySelectedTab As RadRibbonTab = radRibbonBar.SelectedTab
Minimization
RadRibbonBar supports minimization, which means that the ribbon may be hidden so that only its tabs appear. The end-user can toggle the minimization of the ribbon by double-clicking the selected tab.
For more information, please take a look at the Minimization topic.
Events
The RadRibbonBar exposes two events related to the RadRibbonTab element:
- PreviewSelectedTabChanged - event raised when the tab selection is about to be done. The PreviewSelectedTabChanged event handler receives two arguments:
-
The sender argument contains the RadRibbonBar. This argument is of type object, but can be cast to the RadRibbonBar type.
-
The second argument is Telerik.Windows.RadRoutedEventArgs containing all additional information about the event.
Tip |
|---|
|
You can cancel the selection by setting the RadRoutedEventArgs's Handled property to True.
|
CopyXAML
<telerik:RadRibbonBar x:Name="radRibbonBar" PreviewSelectedTabChanged="radRibbonBar_PreviewSelectedTabChanged" />
CopyC#
private void radRibbonBar_PreviewSelectedTabChanged( object sender, RadRoutedEventArgs e )
{
RadRibbonBar ribbonBar = sender as RadRibbonBar;
e.Handled = true;
}
CopyVB.NET
Private Sub radRibbonBar_PreviewSelectedTabChanged(ByVal sender As Object, ByVal e As RadRoutedEventArgs)
Dim ribbonBar As RadRibbonBar = TryCast(sender, RadRibbonBar)
e.Handled = True
End Sub- SelectedTabChanged - event raised after the tab selection is done. The SelectedTabChanged event handler receives two arguments:
-
The sender argument contains the RadRibbonBar. This argument is of type object, but can be cast to the RadRibbonBar type.
-
The second argument is Telerik.Windows.RadRoutedEventArgs containing all additional information about the event.
CopyXAML
<telerik:RadRibbonBar x:Name="radRibbonBar" SelectedTabChanged="radRibbonBar_SelectedTabChanged" />
CopyC#
private void radRibbonBar_SelectedTabChanged( object sender, RadRoutedEventArgs e )
{
RadRibbonBar ribbonBar = sender as RadRibbonBar;
}
CopyVB.NET
Private Sub radRibbonBar_SelectedTabChanged(ByVal sender As Object, ByVal e As RadRoutedEventArgs)
Dim ribbonBar As RadRibbonBar = TryCast(sender, RadRibbonBar)
End Sub
For a full list of the exposed by the RadRibbonBar events, take a look at the
Events - Overview topic.
Customizing the Ribbon Tab
To learn how to change the default appearance of the Ribbon Tab read this topic.
The RadRibbonBar is a complex control and the RibbonTab is only a small part of it. The RadRibbonBar consists of various elements such as:
Additional features that you may find interesting are:
See Also