---
title: "Get owner of context menu on Button"  
description: "Get owner of context menu on Button"  
author: "Jayden Bell"  
published: 2013-08-16  
updated: 2013-08-17  
canonical: https://www.mindstick.com/forum/1387/get-owner-of-context-menu-on-button  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# Get owner of context menu on Button

Hi [Developers](https://www.mindstick.com/articles/12875/blunders-you-must-avoid-while-hiring-java-developers-to-get-the-best-fulfilling-your-needs)!

[Title](https://www.mindstick.com/articles/12860/how-to-get-financing-for-salvage-title-cars) just about says it all.I have a lot of buttons, all of them have the same [context](https://www.mindstick.com/forum/23245/what-is-context-in-android) menu, I want to determine from the [click event](https://www.mindstick.com/forum/424/how-to-call-form_paint-event-on-button-click-event) which [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) was rgiht clicked to get there.

This [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) does not work, placementTarget is [null](https://www.mindstick.com/forum/33922/how-to-use-null-coalescing-operator-in-c-sharp):

```
private void mi_Click(object sender, RoutedEventArgs e){        Button contextMenuEzen = null;        MenuItem mnu = sender as MenuItem;        if (mnu != null)        {            ContextMenu ize =(ContextMenu)mnu.Parent;            contextMenuEzen = ize.PlacementTarget as Button;        }}
```

Please help me!

\

## Replies

### Reply by shreesh chandra shukla

Hi!

RoutedEvents don't work exactly like regular events - the signature of the handler is EventHandler(object sender, RoutedEventArgs e). The RoutedEventArgs has a property called OriginalSource that represents the element in your UI that was actually clicked. In contrast, the sender parameter will always be the object on which the [event](https://www.mindstick.com/articles/167719/marquee-hire-benefits-of-event-lighting-hire-london) handler is registered.

Thanks


---

Original Source: https://www.mindstick.com/forum/1387/get-owner-of-context-menu-on-button

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
