WPF contextMenu click issue?

When you right click, you actually also select. So that means you can just do.

Up vote 0 down vote favorite share g+ share fb share tw.

A ListBox and a ContextMenu are created dynamicaly. The ListBox has some items. How do I know the ListBoxItem Text that right mouse button clicked on?

Private void Init2() { ContextMenu contextMenu = new ContextMenu(); MenuItem menuItemOpen = new MenuItem(); menuItemOpen. Click += new RoutedEventHandler(menuItemOpen_Click); contextMenu.Items. Add(menuItemOpen); listBox1.

ContextMenu = contextMenu; } void menuItemOpen_Click(object sender, RoutedEventArgs e) { //How do I know the listItem text that right mouse button clicked on? } wpf link|improve this question asked Apr 2 at 19:09Grienders15239 54% accept rate.

When you right click, you actually also select. So that means you can just do: private void MenuItem_Click(object sender, RoutedEventArgs e) { string selectedListBoxItemText = ((ListBoxItem)listBox1. SelectedItem).Content.ToString()); // do your thing }.

– Grienders Apr 2 at 19:15 Sorry, read the problem incorrectly. Will update answer. – Drew Marsh Apr 2 at 19:20.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions


Thank You!
send