How to get the PlacementTarget on WPF Context menu when item click using MVVM pattern
How to get the PlacementTarget of selected ContextMenu when using MVVM pattern ? I can get PlacementTarget like this when using MenuItem click event. But how it do it MVVM ? public void changeGaugeColor(object sender, RoutedEventArgs e) { MenuItem tempMenuItem = (MenuItem)sender; MenuItem mi = (MenuItem)sender; bd = (BidirectionalDial)cm.PlacementTarget; } I realise that this is an old post, but someone might find this useful to know. Assuming that you have bound your view to your view model, then you can then bind your ContextMenu.DataContext to your view model in the following way: First,