private void AssociatedObject_PreviewMouseDown(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { var parent = WPFUtil.FindLogicalAncestor(AssociatedObject); if (parent != null && parent is MenuItem mi) { mi.IsSubmenuOpen = false; } } }