The control template structure of the RadTreeView
is designed so that the area before the image is used to display other RadTreeViewItem Template
elements that are only visible when specific properties are set (e.g. loading indicator, expander arrow, CheckBox). This is why the Click
event is invoked even when clicking before the image.
However, there are two approaches that you can use to implement your requirements.
The first one is to handle the MouseLeftButtonUp
as described in my previous reply. In the handler you can check the OriginalSource
of the event and based on it display the DefaultImageSource
sender, MouseButtonEventArgs e)
Image || e.OriginalSource
TextBlock || e.OriginalSource
Please note that in order to get the RadTreeViewItem
where the click is initiated, we use the ParentOfType<T>
On the other hand, the same functionality can be achieved by editing the Style
of the RadTreeViewItem
. I demonstrated this approach in the attached sample where I have extracted the styles used by the RadTreeViewItem
in the attached project.
The changes I made to its ControlTemplate
are as follows:
- Exchanged the names of the Grid that contains the header parts of the item and the Grid that hosts the header of the item as shown in the picture
You can see the default TemplateStructure
of the RadTreeViewItem here
- Made both background colors Transparent in order to invoke the Click event
- Changed the HorizontalAlignment property of the nested Grid (now called HeaderRow) to Stretch.
Keep in mind that if you are using the DefaultImageSrc
property of the RadTreeViewItem
, the image might not invoke the Click
event because it is outside the Grid
These approaches are demonstrated in the attached solution. In order to run the first approach you have to delete the UserControl.Resources
section and uncomment the attachment of the EventHandler
in the CodeBehind
Take a look at it and let us know if it works for you. If you have any questions don't hesitate to ask.
Pavel R. Pavlov
the Telerik team