I got a Grid with controls such System.Windows.Controls.Image and Labels in each RowDefinition of my Grid. The problem is when I do the right click contextmenu it works and I ca
maybe something like this?:
private void DoStuff(object sender, RoutedEventArgs e)
{
// Get the selected MenuItem
var menuItem = (MenuItem)sender;
// Get the ContextMenu for the menuItem
var ctxtMenu = (ContextMenu)menuItem.Parent;
// Get the placementTarget of the ContextMenu
var item = (DataGrid)ctxtMenu.PlacementTarget;
// Now you can get selected item/cell etc.. and cast it to your object
// example:
//var someObject = (SomeObject)item.SelectedCells[0].Item;
// rest of code....
}