/// <summary> /// Runs context menu at current mouse position</summary> /// <param name="service">Context menu service</param> /// <param name="commandTags">Command tags for commands to include on menu</param> public static void RunContextMenu(this IContextMenuService service, IEnumerable <object> commandTags) { var menu = service.GetContextMenu(commandTags); menu.Placement = PlacementMode.MousePoint; OpenContextMenuIfNotEmpty(menu); }
/// <summary> /// Runs context menu at screen offset (device independant pixels)</summary> /// <param name="service">Context menu service</param> /// <param name="commandTags">Command tags for commands to include on menu</param> /// <param name="screenOffset">Screen offset</param> public static void RunContextMenu(this IContextMenuService service, IEnumerable <object> commandTags, Point screenOffset) { var menu = service.GetContextMenu(commandTags); menu.Placement = PlacementMode.AbsolutePoint; menu.HorizontalOffset = screenOffset.X; menu.VerticalOffset = screenOffset.Y; OpenContextMenuIfNotEmpty(menu); }
/// <summary> /// Runs context menu at offset to provided UIElement (device independant pixels)</summary> /// <param name="service">Context menu service</param> /// <param name="commandTags">Command tags for commands to include on menu</param> /// <param name="element">UIElement for positioning</param> /// <param name="offset">Screen offset</param> public static void RunContextMenu(this IContextMenuService service, IEnumerable <object> commandTags, UIElement element, Point offset) { var menu = service.GetContextMenu(commandTags); menu.Placement = PlacementMode.Relative; menu.PlacementTarget = element; menu.HorizontalOffset = offset.X; menu.VerticalOffset = offset.Y; OpenContextMenuIfNotEmpty(menu); }