Example #1
0
        private static void ShowSystemMenu(Window window)
        {
            // Note: as we fetch for the content presenter, this command is a bit dependent of the window control template.
            // But both our template and the default (Aero) seems to use one so this is probably ok.
            var presenter = window.FindVisualChildrenOfType<ContentPresenter>().FirstOrDefault(x => Equals(x.FindVisualParentOfType<Control>(), window));
            if (presenter == null)
                throw new InvalidOperationException("The given window does not contain a ContentPresenter.");

            System.Windows.SystemCommands.ShowSystemMenu(window, presenter.PointToScreen(new Point(0, 0)));
        }