Edit Treeview Node from ViewModel

6 posts, 0 answers
  1. bluewater
    bluewater avatar
    24 posts
    Member since:
    Jan 2007

    Posted 13 Jan 2012 Link to this post

    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.
  2. bluewater
    bluewater avatar
    24 posts
    Member since:
    Jan 2007

    Posted 15 Jan 2012 Link to this post

    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/ 

  3. DevCraft banner
  4. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 16 Jan 2012 Link to this post

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

  5. bluewater
    bluewater avatar
    24 posts
    Member since:
    Jan 2007

    Posted 17 Jan 2012 Link to this post

    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?
  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 17 Jan 2012 Link to this post

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

  7. bluewater
    bluewater avatar
    24 posts
    Member since:
    Jan 2007

    Posted 17 Jan 2012 Link to this post

    thx, I appeciate your support.
Back to Top
DevCraft banner