This problem relates mainly to context menus, but in my specific case it\'s about a TreeView control.
The TreeView item contains a StackPanel, and on that StackPanel
A quick solution might be to simply register the TreeView's MouseRightButtonDown event, check if the click was on a TreeViewItem and select it:
TreeView.MouseRightButtonDown += Tv_MouseRightButtonDown;
void Tv_MouseRightButtonDown(object sender, MouseButtonEventArgs e) {
var tvItem = e.Source as TreeViewItem;
if (tvItem != null) {
tvItem.IsSelected = true;
}
}