private void ShowContextMenu(SampleDataModel data, UIElement target, Point offset) { var MyFlyout = this.Resources["SampleContextMenu"] as MenuFlyout; System.Diagnostics.Debug.WriteLine("MenuFlyout shown '{0}', '{1}'", target, offset); MyFlyout.ShowAt(target, offset); }
protected override void OnKeyDown(KeyRoutedEventArgs e) { // Handle Shift+F10 // Handle MenuKey if (e.Key == Windows.System.VirtualKey.Shift) { _IsShiftPressed = true; } // Shift+F10 else if (_IsShiftPressed && e.Key == Windows.System.VirtualKey.F10) { var FocusedElement = FocusManager.GetFocusedElement() as UIElement; SampleDataModel MyObject = null; if (FocusedElement is ContentControl) { MyObject = ((ContentControl)FocusedElement).Content as SampleDataModel; } ShowContextMenu(MyObject, FocusedElement, new Point(0, 0)); e.Handled = true; } // The 'Menu' key next to Right Ctrl on most keyboards else if (e.Key == Windows.System.VirtualKey.Application || e.Key == Windows.System.VirtualKey.GamepadMenu) { var FocusedElement = FocusManager.GetFocusedElement() as UIElement; SampleDataModel MyObject = null; if (FocusedElement is ContentControl) { MyObject = ((ContentControl)FocusedElement).Content as SampleDataModel; } ShowContextMenu(MyObject, FocusedElement, new Point(0, 0)); e.Handled = true; } base.OnKeyDown(e); }
public Scenario1() { this.InitializeComponent(); AllItems = SampleDataModel.GetSampleData().ToList(); this.DataContext = this; }