Question: Let's say I have an image in a CBitmap with a color that signifies a transparent pixel (in my case it's magenta). Can I create a HRGN or a CRgn for the image that includes all the pixels except the magenta ones?

Answer: 
i have use a different approach for getting the sender button of my context menu. i have made an event on the "hold\_click" 

where i have get back the content of the button in a public string

```
private void GestureListener_DoubleTap(object sender, GestureEventArgs e)
{
    Button clikance = (Button)sender;
    ButtonEnvoyeur = Convert.ToString(clikance.Content);
}

```
If you look in the debugger at the point where the exception is raised, you'll see that **sender** isn't a `Button`, so trying to do an explicit cast to `Button` will obviously throw an `InvalidCastException`. 

You can use the `VisualTreeHelper` to walk up the tree from your actual sender to the `Button` element:

```
VisualTreeHelper.GetParent((sender as DependencyObject));
```

**UPDATE:** In your instance **sender** is the `MenuItem` in the `ContextMenu`. You can get to the parent `ContextMenu` from the `MenuItem` by using the `VisualTreeHelper`, but unfortunately, `ContextMenu` does not expose any public members that enable you to access the owner; the `Owner` property is internal. You could get the source code for the Toolkit and expose the `Owner` property as publi instead, or use a completely different approach.

Have you thought of using an MVVM framework (such as [MVVM Light](http://www.galasoft.ch/mvvm/getstarted/)) to wire up commands to these context menu items? Your current approach is very fragile and will break as soon as you change the visual tree. If you used commands, you could pass any additional information that you need for processing via the command parameter.