Custom Context menu

4 posts, 0 answers
  1. Harsh
    Harsh avatar
    8 posts
    Member since:
    Jan 2009

    Posted 04 Feb 2009 Link to this post

    Hi,
     I want custom context menu for parent and child node. I am binding my tree with a collection in code behind. How can I achive my goal?
     
  2. Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 04 Feb 2009 Link to this post

    Hello Harsh,

    What you are asking should be pretty straightforward. Please refer to the following articles regarding the use of context menu  in WPF:

    http://msdn.microsoft.com/en-us/library/ms742558(VS.85).aspx
    http://msdn.microsoft.com/en-us/library/ms753329(VS.85).aspx
    http://msdn.microsoft.com/en-us/library/ms752343(VS.85).aspx

    Let me know if you still have problems after reading the above articles.

    Best wishes,
    Tihomir Petkov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Harsh
    Harsh avatar
    8 posts
    Member since:
    Jan 2009

    Posted 05 Feb 2009 Link to this post

    I am able to populate the contextmenu for tree but on right click on first load I do not get any contextmenu but on right click twice I get the menu. I get this problem only on forst load of the page. I have not define any contextmenu for RadTreeView in the .xaml

    Code in xaml.cs:

    RadTreeView.ContextMenuOpening +=

    new ContextMenuEventHandler(RadTreeView_ContextMenuOpening);

     

     

    void RadTreeView_ContextMenuOpening(object sender, ContextMenuEventArgs e) {

     

     

    RadTreeView.ContextMenu = GetContextMenu();

     

    }

     

    private

    ContextMenu GetContextMenu() {

     

     

    MenuItem objMenuItemNew, objMenuItemDelete;

     

     

    ContextMenu objContextMenu = new ContextMenu();

     

    objMenuItemNew =

    new MenuItem();

     

    objMenuItemNew.Header =

    "New";

     

    objContextMenu.Items.Add(objMenuItemNew);

    objMenuItemNew.Click +=

    new RoutedEventHandler(objMenuItemNew_Click);

     

    objMenuItemDelete =

    new MenuItem();

     

    objMenuItemDelete.Header =

    "Delete";

     

    objContextMenu.Items.Add(objMenuItemDelete);

     

    return objContextMenu;

     

    }

  4. Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 09 Feb 2009 Link to this post

    Hi Harsh,

    Please refer to the sample project I attached to the reply to your other post regarding the use of context menu in treeview.

    Sincerely yours,
    Tihomir Petkov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top