static MenuItem GetItemInTarget(UIElement target, int[] indices, out WPFContextMenu.Clean cleaner)
        {
            var menu = WPFContextMenu.OpenMenu(target, out cleaner);
            var item = HeaderedItemsControlUtility.GetItem <MenuItem>(menu, indices, ShowNextItem);

            return(item);
        }
        static void EmulateClick(MenuItem item, WPFContextMenu.Clean clean)
        {
            IInvokeProvider invoker = new MenuItemAutomationPeer(item);

            item.Focus();
            invoker.Invoke();
            InvokeUtility.DoEvents();
            clean();
        }