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

Edit Treeview Node from ViewModel

5 Answers 115 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Frank
Top achievements
Rank 1
Frank asked on 13 Jan 2012, 12:44 PM
I have a treeview with an attached context menu. The context menu items have commands which are pointing to the view model, like so (shortened version):
<telerik:RadContextMenu.ContextMenu>    
        <
telerik:RadContextMenu x:Name="ContextMenu" Opened="ContextMenuOpened">
            <
telerik:RadMenuItem Header="Edit Group" Command="{Binding EditCommand}" Name="EditNode"/>
        </
telerik:RadContextMenu>
</
telerik:RadContextMenu.ContextMenu>

Now what I'd like to do is set the current treeview item to IsInEditMode=true - basically like pressing F2, but raised by the context menu item click, and in a MVVM context.

I can set my property from MVVM, but how to bind/reference the clicked tree view item?
I suppose I should pass a command parameter but I just can't figure it out.

Your help much appreciated - thx.

5 Answers, 1 is accepted

Sort by
0
Frank
Top achievements
Rank 1
answered on 15 Jan 2012, 10:27 AM
Never mind, figured it out: Just raise an event (urgh..). Got it from here: http://blog.tonysneed.com/2011/01/28/tackling-the-problem-of-modal-dialogs-in-mvvm/ 

0
Petar Mladenov
Telerik team
answered on 16 Jan 2012, 04:19 PM
Hello frankd ,

 Please also find a possible approach realized in the attached sample and let us know if it fits in your scenario.

Kind regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Frank
Top achievements
Rank 1
answered on 17 Jan 2012, 01:03 PM
Petar,

thank you very much for looking into this. Your solution certainly makes for very streamlined code. I am using RIA services - would I have to add the IsInEditMode to all of my Entities definitions then?
0
Petar Mladenov
Telerik team
answered on 17 Jan 2012, 01:44 PM
Hello Frankd,

 Yes, you will have to add a boolean property to your Entities classes or their wrapper classes.

All the best,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Frank
Top achievements
Rank 1
answered on 17 Jan 2012, 01:46 PM
thx, I appeciate your support.
Tags
TreeView
Asked by
Frank
Top achievements
Rank 1
Answers by
Frank
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or