New to Telerik UI for WPF? Download free 30-day trial

Selection

RadRibbonView 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. WPF RadRibbonView Selected Ribbon Tab

Properties

  • RadRibbonView.SelectedItem - sets or gets the currently selected ribbon tab item.

    If the RadRibbonView control is bound to a custom collection, then the property SelectedItem will not return RadRibbonTab as you might expect, but item of the type the source collection contains.

  • RadRibbonView.SelectedTab - gets the currently selected RadRibbonTab container.

  • RadRibbonView.SelectedIndex - sets or gets the index of the currently selected ribbon tab item.

  • RadRibbonTab.IsSelected - if you want to make a tab selected, just set its IsSelected property to True; otherwise set it to False.

Events

  • PreviewSelectionChanged - event raised when the tab selection is about to be done. The PreviewSelectionChanged event handler receives two arguments:

    • The sender argument contains the RadRibbonView. This argument is of type object, but can be cast to the RadRibbonView type.
    • The second argument is RadSelectionChangedEventArgs containing all additional information about the event:
      • AddedItems - an IList collection of the selected items
      • RemovedItems - an IList collection of the unselected items

    You can cancel the selection by setting the RadSelectionChangedEventArgs's Handled property to True.

  • SelectionChanged - event raised after the tab selection is done. The SelectionChanged event handler receives two arguments:

    • The sender argument contains the RadRibbonView. This argument is of type object, but can be cast to the RadRibbonView type.
    • The second argument is RadSelectionChangedEventArgs containing all additional information about the event:
      • AddedItems - an IList collection of the selected items
      • RemovedItems - an IList collection of the unselected items

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

<telerik:RadRibbonView x:Name="radRibbonView" PreviewSelectionChanged="radRibbonView_PreviewSelectionChanged" SelectionChanged="radRibbonView_SelectionChanged"> 
... 
</telerik:RadRibbonView> 

Below is a sample implementation of both of the event handlers:

private void radRibbonView_PreviewSelectionChanged(object sender, RadSelectionChangedEventArgs e) 
{ 
 // Get the ribbonView 
 RadRibbonView ribbonView = sender as RadRibbonView; 
 //Get the selected items 
 IList selectedItems = e.AddedItems; 
 //Get the unselected items 
 IList unselectedItems = e.RemovedItems; 
 // Cancel the selection 
 e.Handled = true; 
} 
private void radRibbonView_SelectionChanged(object sender, RadSelectionChangedEventArgs e) 
{ 
 // Get the ribbonView 
 RadRibbonView ribbonView = sender as RadRibbonView; 
 //Get the selected items 
 IList selectedItems = e.AddedItems; 
 //Get the unselected items 
 IList unselectedItems = e.RemovedItems; 
} 
Private Sub radRibbonView_PreviewSelectionChanged(sender As Object, e As RadSelectionChangedEventArgs) 
 ' Get the ribbonView' 
 Dim ribbonView As RadRibbonView = TryCast(sender, RadRibbonView) 
 'Get the selected items' 
 Dim selectedItems As IList = e.AddedItems 
 'Get the unselected items' 
 Dim unselectedItems As IList = e.RemovedItems 
 ' Cancel the selection' 
 e.Handled = True 
End Sub 
Private Sub radRibbonView_SelectionChanged(sender As Object, e As RadSelectionChangedEventArgs) 
 ' Get the ribbonView' 
 Dim ribbonView As RadRibbonView = TryCast(sender, RadRibbonView) 
 'Get the selected items' 
 Dim selectedItems As IList = e.AddedItems 
 'Get the unselected items' 
 Dim unselectedItems As IList = e.RemovedItems 
End Sub 

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

In this article