Overview
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.
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.
When a RadTreeViewItem is edited and the changes are committed, the lifecycle of the raised events is the following:
- PreviewEditStarted
- EditStarted
- PreviewEdited
- Edited
When a RadTreeViewItem is edited and the changes are canceled, the lifecycle of the raised events is the following:
- PreviewEditStarted
- EditStarted
- PreviewEditCanceled
- 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.
When working with selection the lifecycle of the raised events is the following:
- PreviewSelected
- Selected
- SelectionChanged
- PreviewUnselected
- 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.
When expanding and collapsing items the lifecycle of the raised events is the following:
- PreviewExpanded
- Expanded
- PreviewCollapsed
- 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.
When checking and unchecking items the lifecycle of the raised events is the following:
- PreviewChecked
- Checked
- PreviewUnchecked -Unchecked
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, that gives you access to the source and the original source of the event as follows:
- OriginalSource - the original source of the event
- Source - the original source of the event
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.
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.