RadControls for WPF

This topic covers the specific events exposed by the RadTreeView control. The events are grouped by their general purpose.

Click Events

RadTreeView exposes the following events when a RadTreeViewItem is clicked with the Mouse left button:

  • ItemClick – raised on MouseLeftButtonUp when a RadTreeViewItem is clicked with Mouse left button.
  • ItemDoubleClick – raised on MouseLeftButtonUp when a RadTreeViewItem is double clicked with Mouse left button. The time slot between two clicks must be less than or equal to 300ms in order to be registered as a double click.

RadTreeViewItem exposes the following events:

  • Click – raised on MouseLeftButtonUp when the item is clicked with Mouse left button.
  • DoubleClick – raised on MouseLeftButtonUp when the item is double clicked with Mouse left button. The time slot between the two clicks must be less than or equal to 300ms to register these clicks as a double click.

Click Events sequence.

Currently a successful RadTreeViewItem double click fires the following events:

  • ItemClick event of the RadTreeView
  • DoubleClick event of the RadTreeViewItem
  • ItemDoubleClick event of the RadTreeView
  • Click event of the RadTreeViewItem
  • ItemClick event of the RadTreeView

Edit Events

RadTreeView exposes the following events regarding the data manipulation:

  • PreviewEditStarted- raised just before the editing of an item has started. This is a wrapper for the EditableHeaderedItemsControl.PreviewEditStarted routed event. The PreviewEditStarted event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadTreeViewItemEditedEventArgs object.
  • EditStarted - raised when the editing of an item has just started. This is a wrapper for the EditableHeaderedItemsControl.EditStarted routed event. The EditStarted event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadTreeViewItemEditedEventArgs object.
  • PreviewEdited - occurs before a treeview item has accepted the new Edited data. The PreviewEdited event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadTreeViewItemEditedEventArgs object.
  • Edited - raised when the editing of an item has been committed. The Edited event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadTreeViewItemEditedEventArgs object.
  • PreviewEditCanceled - raised just before the item editing has been canceled. This is a wrapper for the EditableHeaderedItemsControl.
  • PreviewEditCanceled routed event. The PreviewEditCanceled event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadTreeViewItemEditedEventArgs object.
  • EditCanceled - raised when the item editing has been canceled. This is a wrapper for the EditableHeaderedItemsControl.EditCanceled routed event. The EditCanceled event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadTreeViewItemEditedEventArgs object.
Tip

When a RadTreeViewItem is edited and the changes are committed, the lifecycle of the raised events is:

  1. PreviewEditStarted
  2. EditStarted
  3. PreviewEdited
  4. Edited
Tip

When a RadTreeViewItem is edited and the changes are canceled, the lifecycle of the raised events is:

  1. PreviewEditStarted
  2. EditStarted
  3. PreviewEditCanceled
  4. EditCanceled

Selection Events

RadTreeView exposes the following events regarding the selection:

  • PreviewSelected - occurs before a child treeview item is selected. The PreviewSelected event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
  • Selected - occurs when a child RadTreeView item has been selected. The Selected event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
  • SelectionChanged - occurs after the value of the SelectedItems property of a tree is changed. The SelectionChanged event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A SelectionChangedEventArgs object.
  • PreviewUnselected - occurs before a child treeview item is unselected. The PreviewUnselected event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
  • Unselected - occurs when a child treeview item has been unselected. The Unselected event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
Tip

When working with selection the lifecycle of the raised events is:

  1. PreviewSelected
  2. Selected
  3. SelectionChanged
  4. PreviewUnselected
  5. Unselected

Expand\Collapse Events

RadTreeView exposes the following events regarding the expanding and collapsing of treeview items:

  • PreviewExpanded - occurs before a child treeview item is expanded. The PreviewExpanded event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
  • Expanded - occurs when a child treeview item has been expanded. The Expanded event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
  • PreviewCollapsed - occurs before a child treeview item is collapsed. The PreviewCollapsed event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
  • Collapsed - occurs when a child treeview item has been collapsed. The Collapsed event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
Tip

When expanding and collapsing items the lifecycle of the raised events is:

  1. PreviewExpanded
  2. Expanded
  3. PreviewCollapsed
  4. Collapsed

Check\Uncheck Events

RadTreeView exposes the following events regarding the checking and unchecking of treeview items:

  • PreviewChecked - occurs before a child treeview item is checked. The PreviewChecked event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
  • Checked - occurs when a child treeview item has been checked. The Checked event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
  • PreviewUnchecked - occurs before a child treeview item is unchecked. The PreviewUnchecked event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
  • Unchecked - occurs when a child treeview item has been unchecked. The Unchecked event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
Tip

When checking and unchecking items the lifecycle of the raised events is:

  1. PreviewChecked
  2. Checked
  3. PreviewUnchecked
  4. Unchecked

Drag and Drop Events

RadTreeView exposes the following events regarding the drag and drop:

  • PreviewDragStarted - occurs before the drag is started. The PreviewDragStarted event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadTreeViewDragEventArgs object.
  • DragStarted - occurs when the drag has started. The DragStarted event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadTreeViewDragEventArgs object.
  • PreviewDragEnded - occurs before the drag has been ended. The PreviewDragEnded event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadTreeViewDragEndedEventArgs object.
  • DragEnded - occurs when the drag has ended. The DragEnded event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadTreeViewDragEndedEventArgs object.
Tip

When working with drag and drop the lifecycle of the raised events is:

  1. PreviewDragStarted
  2. DragStarted
  3. PreviewDragEnded
  4. DragEnded
Tip

Handling the PreviewDragEnded event will cancel the drop operation. This is useful, when you want to cancel adding/removing items from the RadTreeView's ItemsCollection.

CopyC#
private void radTreeView_PreviewDragEnded( object sender, RadTreeViewDragEndedEventArgs e )
{
     e.Handled = true;
}

CopyVB.NET
Private Sub radTreeView_PreviewDragEnded(sender As Object, e As RadTreeViewDragEndedEventArgs)
       e.Handled = True
End Sub

Other Events

  • LoadOnDemand - occurs when a child treeview item is loading its child items on demand. The LoadOnDemand event handler receives two arguments:
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
Note

For more information about the load on demand feature, take a look at the Load on Demand topic.

  • ItemPrepared - occurs when a child RadTreeViewItem has been prepared and is now ready for use.
    • The sender argument contains the RadTreeView. This argument is of type object, but can be cast to the RadTreeView type.
    • A RadRoutedEventArgs object.
Note

The ItemPrepared event is a very important event. It is used to perform binding of RadTreeViewItem properties to the data objects. For more information, take a look at the Working with ItemPrepared Event topic.

See Also