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

Custom Context menu

3 Answers 210 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Harsh
Top achievements
Rank 1
Harsh asked on 04 Feb 2009, 06:56 AM
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?
 

3 Answers, 1 is accepted

Sort by
0
Tihomir Petkov
Telerik team
answered on 04 Feb 2009, 08:25 AM
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.
0
Harsh
Top achievements
Rank 1
answered on 05 Feb 2009, 06:24 AM
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;

 

}

0
Tihomir Petkov
Telerik team
answered on 09 Feb 2009, 01:03 PM
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.
Tags
TreeView
Asked by
Harsh
Top achievements
Rank 1
Answers by
Tihomir Petkov
Telerik team
Harsh
Top achievements
Rank 1
Share this question
or