Click event of the TreeViewItem Control

2 posts, 0 answers
  1. Rama
    Rama avatar
    8 posts
    Member since:
    Sep 2012

    Posted 09 Jan 2013 Link to this post


    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. ?

  2. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 14 Jan 2013 Link to this post

    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.

  3. DevCraft R3 2016 release webinar banner
Back to Top