Get Text of a ContextMenu.ItemsSource generated MenuItem in WPF?

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

I´ve got a Click-method of a MenuItem in a ContextMenu. In this method, I need the text of the item I´ve clicked. Here´s the code: private void menuItemKostenstellen_Click(object sender, RoutedEventArgs e) { } I already tried with e.

Source but that didn´t work. How can I get this? C# wpf contextmenu menuitem link|improve this question edited Jan 5 at 12:20LPL1,6553712 asked Jan 5 at 9:37user8966921776 70% accept rate.

Please show the code how you react to the menu item click. – Tim Cools Jan 5 at 9:39.

Use following: LinkedList kliste = kosrep. GetKostenstellen(); menuItemKostenstellenunter. ItemsSource = kliste.

Try this private void menuItemKostenstellen_Click(object sender, RoutedEventArgs e) { MenuItem mi = sender as MenuItem; string title = mi.Header.ToString(); }.

Thank you. With this code, I get the Header of my MenuItems. I need to get one level depper.

– user896692 Jan 5 at 10:14 What do you mean one level deeper? Can you show picture? Also use the properties of mi to get anything that exists under it – Haris Hasan Jan 5 at 10:33 Ok, heres the picture: link/link.

When I write mi.Header.ToString() I get "Kostenstellen" but I need "Reschinator", "Steuern" ... – user896692 Jan 5 at 10:40 1 You should handle click on sub menu item then. – Amit Jan 5 at 11:09 LinkedList kliste = kosrep. GetKostenstellen(); menuItemKostenstellenunter.

ItemsSource = kliste; But thats not possible like you see above – user896692 Jan 5 at 11:17.

Use ItemContainerStyle Property for Click Event on all MenuItems.

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