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

Working with MouseLeftButtonDown Event

The purpose of this tutorial is to show you how to handle the MouseLeftButtonDown event of the RadTreeView/Item.

Attaching to the MouseLeftButtonDown Event

Probably the first solution crossing your mind is to attach to the MouseLeftButtonDown directly, using the exposed by the RadTreeView object event.

<telerik:RadTreeView x:Name="radTreeView" MouseLeftButtonDown="radTreeView_MouseLeftButtonDown"/> 

And this is the most straight-forward way to do it. However, if you use the above approach, you won't be able to track the MouseLeftButtonDown event. The reason - by design, the RadTreeView items mark the MouseLeftButtonDown event as handled.

Telerik RadControls API allows you to also listen for events that have been already handled. You should attach to the MouseLeftButtonDown event using the AddHandler extension methods. Check out the code snippet below and be sure that you are using/importing the Telerik.Windows namespace.

using Telerik.Windows; 
this.radTreeView.AddHandler(RadTreeViewItem.MouseLeftButtonDownEvent, new MouseButtonEventHandler(this.radTreeView_MouseLeftButtonDown), true); 
private void radTreeView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
{ 
    Telerik.Windows.Controls.RadTreeView treeView = sender as Telerik.Windows.Controls.RadTreeView; 
} 
Imports Telerik.Windows 
Me.radTreeView.AddHandler 
Private Sub radTreeView_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs) 
    Dim treeView As Telerik.Windows.Controls.RadTreeView = TryCast(sender, Telerik.Windows.Controls.RadTreeView) 
End Sub 

See Also

In this article