RadControls for WPF

RadRibbonBar supports single RadRibbonTab selection. You can select it either run-time by clicking with your mouse on the appropriate tab header or programmatically via the properties described below.

Properties

  • RadRibbonBar.SelectedTab - sets or gets the currently selected ribbon tab.
  • RadRibbonTab.IsSelected - if you want to make a tab selected, just set its IsSelected property to True, otherwise set it to False.

Events

  • 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.
  • 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.

This code snippet shows you how to attach to the selection events:

CopyXAML
<telerik:RadRibbonBar x:Name="radRibbonBar"
                      SelectedTabChanged="radRibbonBar_SelectedTabChanged"
                      PreviewSelectedTabChanged="radRibbonBar_PreviewSelectedTabChanged"/>

Below is a sample implementation of both event handlers:

CopyC#
private void radRibbonBar_SelectedTabChanged( object sender, Telerik.Windows.RadRoutedEventArgs e )
{
    RadRibbonTab newSelectedTab = ( sender as RadRibbonBar ).SelectedTab;
    MessageBox.Show( "You have selected: " + newSelectedTab.Header );
}

private void radRibbonBar_PreviewSelectedTabChanged( object sender, Telerik.Windows.RadRoutedEventArgs e )
{
    //Cancel the selection
    e.Handled = true;
}
CopyVB.NET
Private Sub radRibbonBar_SelectedTabChanged(sender As Object, e As Telerik.Windows.RadRoutedEventArgs)
 Dim newSelectedTab As RadRibbonTab = (TryCast(sender, RadRibbonBar)).SelectedTab
 MessageBox.Show("You have selected: " + newSelectedTab.Header)
End Sub

Private Sub radRibbonBar_PreviewSelectedTabChanged(sender As Object, e As Telerik.Windows.RadRoutedEventArgs)
 'Cancel the selection
 e.Handled = True
End Sub

For a full list of the exposed by the RadRibbonBar events, take a look at the Events - Overview topic.

See Also