This is a migrated thread and some comments may be shown as answers.

Click event of the TreeViewItem Control

1 Answer 178 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Rama
Top achievements
Rank 1
Rama asked on 10 Jan 2013, 02:07 AM
Hi,

Please help me in finding solution to following scenario.

I have a treeview control populated dynamically. I need a click event for the treeview control in MVVM. and i want to access selected item in
the ViewModel class.

How i can achive that ?

Can you please provide sample snippet for clickevent using MVVM. ?

Thanks
Rama.

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 14 Jan 2013, 07:21 AM
Hi Rama,

 You can check out this approach demonstrating how an event from a UI Control can trigger a Command from your ViewModel. However, it is far away from MVVM to have a reference of your control in your ViewModels. ViewModels should not hold a UI controls / references to controls. 
Typically, RadTreeView's and RadTreeViewItem's properties are bound to properties from your ViewModels. When you invoke a Command from your ViewModels, its execution can change some properties and they will reflect control's properties via the associated bindings.

All the best,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeView
Asked by
Rama
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or