From 2e0f6412ae6b6fbc2c622f7fb5bc07010780ae07 Mon Sep 17 00:00:00 2001 From: Karen Lai <7976322+karenbtlai@users.noreply.github.com> Date: Tue, 15 Mar 2022 16:37:30 -0600 Subject: [PATCH 1/2] update test page with cursor positioned menu flyout --- dev/CommonStyles/TestUI/MenuFlyoutPage.xaml | 22 ++++++++++++++++++- .../TestUI/MenuFlyoutPage.xaml.cs | 19 ++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/dev/CommonStyles/TestUI/MenuFlyoutPage.xaml b/dev/CommonStyles/TestUI/MenuFlyoutPage.xaml index 801218fde8..c2d971d04b 100755 --- a/dev/CommonStyles/TestUI/MenuFlyoutPage.xaml +++ b/dev/CommonStyles/TestUI/MenuFlyoutPage.xaml @@ -9,7 +9,27 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> - + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/CommonStyles/TestUI/MenuFlyoutPage.xaml.cs b/dev/CommonStyles/TestUI/MenuFlyoutPage.xaml.cs index cabf0b0b63..2b926b5050 100644 --- a/dev/CommonStyles/TestUI/MenuFlyoutPage.xaml.cs +++ b/dev/CommonStyles/TestUI/MenuFlyoutPage.xaml.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. +using Windows.Foundation; using Windows.Foundation.Metadata; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; @@ -12,9 +13,12 @@ namespace MUXControlsTestApp [TopLevelTestPage(Name = "MenuFlyout", Icon = "MenuFlyout.png")] public sealed partial class MenuFlyoutPage : TestPage { + private MenuFlyout sharedFlyout; public MenuFlyoutPage() { this.InitializeComponent(); + + sharedFlyout = (MenuFlyout)Resources["SampleContextMenu"]; } private void TestMenuFlyoutItemClick(object sender, object e) @@ -22,5 +26,20 @@ private void TestMenuFlyoutItemClick(object sender, object e) TestMenuFlyoutItemHeightTextBlock.Text = $"{TestMenuFlyoutItem.ActualHeight}"; TestMenuFlyoutItemWidthTextBlock.Text = $"{TestMenuFlyoutItem.ActualWidth}"; } + + private void Grid_ContextRequested(UIElement sender, ContextRequestedEventArgs args) + { + Point point; + var requestedElement = sender as FrameworkElement; + + if (args.TryGetPosition(requestedElement, out point)) + { + sharedFlyout.ShowAt(requestedElement, point); + } + else + { + sharedFlyout.ShowAt(requestedElement); + } + } } } From 88903f44b01fc30ea4658896d9d6a1d9607a4e53 Mon Sep 17 00:00:00 2001 From: Karen Lai <7976322+karenbtlai@users.noreply.github.com> Date: Wed, 16 Mar 2022 11:22:35 -0600 Subject: [PATCH 2/2] changes from comments --- dev/CommonStyles/TestUI/MenuFlyoutPage.xaml | 6 +++--- dev/CommonStyles/TestUI/MenuFlyoutPage.xaml.cs | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dev/CommonStyles/TestUI/MenuFlyoutPage.xaml b/dev/CommonStyles/TestUI/MenuFlyoutPage.xaml index c2d971d04b..c20ca027af 100755 --- a/dev/CommonStyles/TestUI/MenuFlyoutPage.xaml +++ b/dev/CommonStyles/TestUI/MenuFlyoutPage.xaml @@ -27,9 +27,7 @@ - - - + @@ -55,6 +53,8 @@ + +