Пример #1
0
        protected virtual void OnMouseRightButtonUp(object sender, EventArgs e)
        {
            var task = Windows.Invoke(() =>
            {
                var x = default(int);
                var y = default(int);
                MouseHelper.GetPosition(out x, out y);
                DpiHelper.TransformPosition(ref x, ref y);

                Menu.HorizontalOffset = x;
                Menu.VerticalOffset   = y;
                Menu.IsOpen           = true;

                var source = PresentationSource.FromVisual(Menu) as HwndSource;
                if (source != null && source.Handle != IntPtr.Zero)
                {
                    SetForegroundWindow(source.Handle);
                }
            });
        }