wpf - Get owner of context menu on Button -
title says all.i have lot of buttons, of them have same context menu, want determine click event button rgiht clicked there.
this code not work, placementtarget null:
private void mi_click(object sender, routedeventargs e) { button contextmenuezen = null; menuitem mnu = sender menuitem; if (mnu != null) { contextmenu ize =(contextmenu)mnu.parent; contextmenuezen = ize.placementtarget button; } }
please me!
routedevents don't work regular events - signature of handler eventhandler(object sender, routedeventargs e). routedeventargs has property called originalsource represents element in ui clicked. in contrast, sender parameter object on event handler registered.
Comments
Post a Comment