Getting the control of a context menu
I have a context menu that looks like this A |--1 |--2 |--3 I need to access the object that the context menu is called from, after selecting 1 2 or 3 meaning if this is a context menu of a textbox1 then I need to access that object, how do I do that? Forgot to mention, this is a WPF application. so Im using the System.Windows.Controls and the ContextMenu is created programmatically You can walk up the tree and get the control from the ContextMenu.PlacementTarget , e.g. private void MenuItem_Click(object sender, RoutedEventArgs e) { var item = sender as MenuItem; while (item.Parent is MenuItem