diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj
index ce2b4765dbd..ba3b75f9671 100644
--- a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj
+++ b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj
@@ -341,7 +341,6 @@
-
@@ -469,7 +468,6 @@
-
@@ -695,10 +693,6 @@
MarkdownParserPage.xaml
-
-
- MenuPage.xaml
-
MouseCursorPage.xaml
@@ -1172,10 +1166,6 @@
Designer
MSBuild:Compile
-
- MSBuild:Compile
- Designer
-
Designer
MSBuild:Compile
diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Commands/VsCommands.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Commands/VsCommands.cs
deleted file mode 100644
index 41de6099bbc..00000000000
--- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Commands/VsCommands.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Windows.Input;
-using Windows.UI.Popups;
-
-namespace Microsoft.Toolkit.Uwp.SampleApp.Menu.Commands
-{
-#pragma warning disable SA1649 // File name must match first type name
- internal class NewProjectCommand : ICommand
-#pragma warning restore SA1649 // File name must match first type name
- {
- event EventHandler ICommand.CanExecuteChanged
- {
- add
- {
- }
-
- remove
- {
- }
- }
-
- public bool CanExecute(object parameter)
- {
- return true;
- }
-
- public async void Execute(object parameter)
- {
- var dialog = new MessageDialog("Create New Project");
- await dialog.ShowAsync();
- }
- }
-
-#pragma warning disable SA1402 // File may only contain a single class
- internal class NewFileCommand : ICommand
-#pragma warning restore SA1402 // File may only contain a single class
- {
- event EventHandler ICommand.CanExecuteChanged
- {
- add
- {
- }
-
- remove
- {
- }
- }
-
- public bool CanExecute(object parameter)
- {
- return true;
- }
-
- public async void Execute(object parameter)
- {
- var dialog = new MessageDialog("Create New File");
- await dialog.ShowAsync();
- }
- }
-
-#pragma warning disable SA1402 // File may only contain a single class
- internal class GenericCommand : ICommand
-#pragma warning restore SA1402 // File may only contain a single class
- {
- event EventHandler ICommand.CanExecuteChanged
- {
- add
- {
- }
-
- remove
- {
- }
- }
-
- public bool CanExecute(object parameter)
- {
- return true;
- }
-
- public async void Execute(object parameter)
- {
- var dialog = new MessageDialog(parameter.ToString());
- await dialog.ShowAsync();
- }
- }
-}
diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.bind
deleted file mode 100644
index acb89e9136d..00000000000
--- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.bind
+++ /dev/null
@@ -1,228 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.png
deleted file mode 100644
index 09031f8fa40..00000000000
Binary files a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.png and /dev/null differ
diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml
deleted file mode 100644
index 12c596e03de..00000000000
--- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml.cs
deleted file mode 100644
index 06ca9a5b57d..00000000000
--- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using Microsoft.Toolkit.Uwp.UI.Controls;
-using Microsoft.Toolkit.Uwp.UI.Extensions;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-
-namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
-{
- public sealed partial class MenuPage : IXamlRenderListener
- {
- private MenuItem fileMenu;
-
- public MenuPage()
- {
- InitializeComponent();
- Load();
- }
-
- public void OnXamlRendered(FrameworkElement control)
- {
- fileMenu = control.FindChildByName("FileMenu") as MenuItem;
- }
-
- private void Load()
- {
- SampleController.Current.RegisterNewCommand("Append Item to file menu", (sender, args) =>
- {
- if (fileMenu != null)
- {
- var flyoutItem = new MenuFlyoutItem
- {
- Text = "Click to remove"
- };
-
- flyoutItem.Click += (a, b) =>
- {
- fileMenu.Items.Remove(flyoutItem);
- };
-
- fileMenu.Items.Add(flyoutItem);
- }
- });
-
- SampleController.Current.RegisterNewCommand("Prepend Item to file menu", (sender, args) =>
- {
- if (fileMenu != null)
- {
- var flyoutItem = new MenuFlyoutItem
- {
- Text = "Click to remove"
- };
-
- flyoutItem.Click += (a, b) =>
- {
- fileMenu.Items.Remove(flyoutItem);
- };
-
- fileMenu.Items.Insert(0, flyoutItem);
- }
- });
- }
- }
-}
diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json
index 9596ad320a7..3a0bba39ec7 100644
--- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json
+++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json
@@ -239,18 +239,6 @@
"Icon": "/SamplePages/OrbitView/OrbitView.png",
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/OrbitView.md"
},
- {
- "Name": "Menu",
- "Type": "MenuPage",
- "Subcategory": "Menus and Toolbars",
- "About": "This control will be removed in a future major release. Please use the MenuBar control from the WinUI Library instead.",
- "BadgeUpdateVersionRequired": "DEPRECATED",
- "DeprecatedWarning": "This control will be removed in a future major release. Please use the MenuBar control from the WinUI Library instead.",
- "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/Menu",
- "XamlCodeFile": "Menu.bind",
- "Icon": "/SamplePages/Menu/Menu.png",
- "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/Menu.md"
- },
{
"Name": "InAppNotification",
"Type": "InAppNotificationPage",
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuItemMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuItemMetadata.cs
deleted file mode 100644
index 8a63b3992c1..00000000000
--- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuItemMetadata.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common;
-using Microsoft.Windows.Design;
-using Microsoft.Windows.Design.Metadata;
-using Microsoft.Windows.Design.PropertyEditing;
-using System.ComponentModel;
-
-namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
-{
- internal class MenuItemMetadata : AttributeTableBuilder
- {
- public MenuItemMetadata()
- : base()
- {
- AddCallback(typeof(MenuItem),
- b =>
- {
- b.AddCustomAttributes(nameof(MenuItem.Header),
- new PropertyOrderAttribute(PropertyOrder.Early),
- new CategoryAttribute(Properties.Resources.CategoryCommon)
- );
- b.AddCustomAttributes(nameof(MenuItem.IsOpened),
- new CategoryAttribute(Properties.Resources.CategoryCommon)
- );
- b.AddCustomAttributes(nameof(MenuItem.HeaderTemplate),
- new EditorBrowsableAttribute(EditorBrowsableState.Advanced),
- new CategoryAttribute(Properties.Resources.CategoryCommon)
- );
- b.AddCustomAttributes(nameof(MenuItem.Items),
- new PropertyOrderAttribute(PropertyOrder.Early),
- new CategoryAttribute(Properties.Resources.CategoryCommon),
- //The following is necessary because this is a collection of an abstract type, so we help
- //the designer with populating supported types that can be added to the collection
- new NewItemTypesAttribute(new System.Type[] {
- typeof(MenuItem),
- }),
- new AlternateContentPropertyAttribute()
- );
-
- b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false));
- b.AddCustomAttributes(new ToolboxBrowsableAttribute(false));
- }
- );
- }
- }
-}
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuMetadata.cs
deleted file mode 100644
index 164c4fa7b70..00000000000
--- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuMetadata.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common;
-using Microsoft.Windows.Design;
-using Microsoft.Windows.Design.Metadata;
-using Microsoft.Windows.Design.PropertyEditing;
-using System.ComponentModel;
-
-namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
-{
- internal class MenuMetadata : AttributeTableBuilder
- {
- public MenuMetadata()
- : base()
- {
- AddCallback(typeof(Microsoft.Toolkit.Uwp.UI.Controls.Menu),
- b =>
- {
- b.AddCustomAttributes(nameof(Menu.Items),
- new PropertyOrderAttribute(PropertyOrder.Early),
- new CategoryAttribute(Properties.Resources.CategoryCommon),
- //The following is necessary because this is a collection of an abstract type, so we help
- //the designer with populating supported types that can be added to the collection
- new NewItemTypesAttribute(new System.Type[] {
- typeof(MenuItem),
- }),
- new AlternateContentPropertyAttribute()
- );
- b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false));
- }
- );
- }
- }
-}
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj b/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj
index b611399dd13..3c3c3d63e2a 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj
+++ b/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj
@@ -100,8 +100,6 @@
-
-
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Events.cs b/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Events.cs
deleted file mode 100644
index fba628da34e..00000000000
--- a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Events.cs
+++ /dev/null
@@ -1,232 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using Windows.Foundation;
-using Windows.System;
-using Windows.UI.Core;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Input;
-
-namespace Microsoft.Toolkit.Uwp.UI.Controls
-{
- ///
- /// Menu Control defines a menu of choices for users to invoke.
- ///
- public partial class Menu
- {
- private const uint AltScanCode = 56;
- private bool _onlyAltCharacterPressed = true;
- private Control _lastFocusElement;
- private bool _isLostFocus = true;
- private Control _lastFocusElementBeforeMenu;
- private Rect _bounds;
-
- private bool AllowTooltip => (bool)GetValue(AllowTooltipProperty);
-
- private void Menu_Loaded(object sender, RoutedEventArgs e)
- {
- _wrapPanel = ItemsPanelRoot as WrapPanel;
- if (_wrapPanel != null)
- {
- _wrapPanel.Orientation = Orientation;
- }
-
- UpdateMenuItemsFlyoutPlacement();
-
- Window.Current.CoreWindow.PointerMoved -= CoreWindow_PointerMoved;
- LostFocus -= Menu_LostFocus;
- LostFocus += Menu_LostFocus;
- Dispatcher.AcceleratorKeyActivated -= Dispatcher_AcceleratorKeyActivated;
- Window.Current.CoreWindow.KeyDown -= CoreWindow_KeyDown;
- Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated;
- Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
- Window.Current.CoreWindow.PointerMoved += CoreWindow_PointerMoved;
- }
-
- private void Menu_Unloaded(object sender, RoutedEventArgs e)
- {
- Window.Current.CoreWindow.PointerMoved -= CoreWindow_PointerMoved;
- Dispatcher.AcceleratorKeyActivated -= Dispatcher_AcceleratorKeyActivated;
- Window.Current.CoreWindow.KeyDown -= CoreWindow_KeyDown;
-
- // Clear Cache
- foreach (MenuItem menuItem in Items)
- {
- var menuFlyoutItems = menuItem.GetMenuFlyoutItems();
- foreach (var flyoutItem in menuFlyoutItems)
- {
- RemoveElementFromCache(flyoutItem);
- }
-
- RemoveElementFromCache(menuItem);
- }
- }
-
- private void CoreWindow_PointerMoved(CoreWindow sender, PointerEventArgs args)
- {
- // if contained with the whole Menu control
- if (IsOpened && _bounds.Contains(args.CurrentPoint.Position))
- {
- // if hover over current opened item
- if (SelectedMenuItem.ContainsPoint(args.CurrentPoint.Position))
- {
- return;
- }
-
- foreach (MenuItem menuItem in Items)
- {
- if (menuItem.ContainsPoint(args.CurrentPoint.Position))
- {
- SelectedMenuItem.HideMenu();
- menuItem.Focus(FocusState.Keyboard);
- menuItem.ShowMenu();
- }
- }
- }
- }
-
- private void CoreWindow_KeyDown(CoreWindow sender, KeyEventArgs args)
- {
- if (IsInTransitionState)
- {
- return;
- }
-
- if (NavigateUsingKeyboard(args, this, Orientation))
- {
- return;
- }
-
- string gestureKey = MapInputToGestureKey(args.VirtualKey);
-
- if (gestureKey == null)
- {
- return;
- }
-
- if (MenuItemInputGestureCache.ContainsKey(gestureKey))
- {
- var cachedMenuItem = MenuItemInputGestureCache[gestureKey];
- if (cachedMenuItem is MenuFlyoutItem)
- {
- var menuFlyoutItem = (MenuFlyoutItem)cachedMenuItem;
- menuFlyoutItem.Command?.Execute(menuFlyoutItem.CommandParameter);
- }
- }
- }
-
- private void Menu_LostFocus(object sender, RoutedEventArgs e)
- {
- var menuItem = FocusManager.GetFocusedElement() as MenuItem;
-
- if (AllowTooltip)
- {
- HideMenuItemsTooltips();
- }
-
- if (menuItem != null || IsOpened)
- {
- return;
- }
-
- _isLostFocus = true;
- if (!AllowTooltip)
- {
- RemoveUnderlineMenuItems();
- }
- }
-
- private void Dispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
- {
- if (Items.Count == 0)
- {
- return;
- }
-
- _lastFocusElement = FocusManager.GetFocusedElement() as Control;
-
- if (args.KeyStatus.ScanCode != AltScanCode)
- {
- _onlyAltCharacterPressed = false;
- }
-
- if (args.VirtualKey == VirtualKey.Menu)
- {
- if (!IsOpened)
- {
- if (_isLostFocus)
- {
- if (_onlyAltCharacterPressed && args.KeyStatus.IsKeyReleased)
- {
- ((MenuItem)Items[0]).Focus(FocusState.Programmatic);
-
- if (!(_lastFocusElement is MenuItem))
- {
- _lastFocusElementBeforeMenu = _lastFocusElement;
- }
- }
-
- if (AllowTooltip)
- {
- ShowMenuItemsToolTips();
- }
- else
- {
- UnderlineMenuItems();
- }
-
- if (args.KeyStatus.IsKeyReleased)
- {
- _isLostFocus = false;
- }
- }
- else if (args.KeyStatus.IsKeyReleased)
- {
- HideToolTip();
- _lastFocusElementBeforeMenu?.Focus(FocusState.Keyboard);
- }
- }
- }
- else if ((args.KeyStatus.IsMenuKeyDown || !_isLostFocus) && args.KeyStatus.IsKeyReleased)
- {
- var gestureKey = MapInputToGestureKey(args.VirtualKey, !_isLostFocus);
- if (gestureKey == null)
- {
- return;
- }
-
- if (MenuItemInputGestureCache.ContainsKey(gestureKey))
- {
- var cachedMenuItem = MenuItemInputGestureCache[gestureKey];
- if (cachedMenuItem is MenuItem)
- {
- var menuItem = (MenuItem)cachedMenuItem;
- menuItem.ShowMenu();
- menuItem.Focus(FocusState.Keyboard);
- }
- }
- }
-
- if (args.KeyStatus.IsKeyReleased && args.EventType == CoreAcceleratorKeyEventType.KeyUp)
- {
- _onlyAltCharacterPressed = true;
- _isLostFocus = true;
- HideToolTip();
- }
- }
-
- private void HideToolTip()
- {
- if (AllowTooltip)
- {
- HideMenuItemsTooltips();
- }
- else
- {
- RemoveUnderlineMenuItems();
- }
- }
- }
-}
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Extensions.cs b/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Extensions.cs
deleted file mode 100644
index 9cf5afc5e40..00000000000
--- a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Extensions.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using Windows.UI.Xaml;
-
-namespace Microsoft.Toolkit.Uwp.UI.Controls
-{
- ///
- /// Menu Control defines a menu of choices for users to invoke.
- ///
- public partial class Menu
- {
- private const string InputGestureTextName = "InputGestureText";
- private const string AllowTooltipName = "AllowTooltip";
-
- ///
- /// Sets the text describing an input gesture that will call the command tied to the specified item.
- ///
- public static readonly DependencyProperty InputGestureTextProperty = DependencyProperty.RegisterAttached(InputGestureTextName, typeof(string), typeof(FrameworkElement), new PropertyMetadata(null, InputGestureTextChanged));
-
- private static void InputGestureTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
- {
- var element = sender as FrameworkElement;
-
- var inputGestureValue = element?.GetValue(InputGestureTextProperty).ToString();
- if (string.IsNullOrEmpty(inputGestureValue))
- {
- return;
- }
-
- inputGestureValue = inputGestureValue.ToUpper();
- if (MenuItemInputGestureCache.ContainsKey(inputGestureValue))
- {
- MenuItemInputGestureCache[inputGestureValue] = element;
- return;
- }
-
- MenuItemInputGestureCache.Add(inputGestureValue.ToUpper(), element);
- }
-
- ///
- /// Gets InputGestureText attached property
- ///
- /// Target MenuFlyoutItem
- /// Input gesture text
- public static string GetInputGestureText(FrameworkElement obj)
- {
- return (string)obj.GetValue(InputGestureTextProperty);
- }
-
- ///
- /// Sets InputGestureText attached property
- ///
- /// Target MenuFlyoutItem
- /// Input gesture text
- public static void SetInputGestureText(FrameworkElement obj, string value)
- {
- obj.SetValue(InputGestureTextProperty, value);
- }
-
- ///
- /// Gets or sets a value indicating whether to allow tooltip on alt or not
- ///
- public static readonly DependencyProperty AllowTooltipProperty = DependencyProperty.RegisterAttached(AllowTooltipName, typeof(bool), typeof(Menu), new PropertyMetadata(false));
-
- ///
- /// Gets AllowTooltip attached property
- ///
- /// Target Menu
- /// AllowTooltip
- public static bool GetAllowTooltip(Menu obj)
- {
- return (bool)obj.GetValue(AllowTooltipProperty);
- }
-
- ///
- /// Sets AllowTooltip attached property
- ///
- /// Target Menu
- /// AllowTooltip
- public static void SetAllowTooltip(Menu obj, bool value)
- {
- obj.SetValue(AllowTooltipProperty, value);
- }
- }
-}
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Logic.cs b/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Logic.cs
deleted file mode 100644
index 84fe733e1c4..00000000000
--- a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Logic.cs
+++ /dev/null
@@ -1,303 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Linq;
-using System.Text;
-using Windows.Foundation;
-using Windows.System;
-using Windows.UI.Core;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Controls.Primitives;
-using Windows.UI.Xaml.Input;
-
-namespace Microsoft.Toolkit.Uwp.UI.Controls
-{
- ///
- /// Menu Control defines a menu of choices for users to invoke.
- ///
- public partial class Menu
- {
- private const string CtrlValue = "CTRL";
- private const string ShiftValue = "SHIFT";
- private const string AltValue = "ALT";
-
- ///
- /// Gets or sets the current flyout placement, internal because the child menu item needs it to respect the menu direction of submenus
- ///
- internal FlyoutPlacementMode? CurrentFlyoutPlacement { get; set; }
-
- private static bool NavigateUsingKeyboard(KeyEventArgs args, Menu menu, Orientation orientation)
- {
- var element = FocusManager.GetFocusedElement();
-
- if (element is MenuFlyoutPresenter &&
- ((args.VirtualKey == VirtualKey.Down) ||
- (args.VirtualKey == VirtualKey.Up) ||
- (args.VirtualKey == VirtualKey.Left) ||
- (args.VirtualKey == VirtualKey.Right)))
- {
- // Hack to delay and let next element get focus
- FocusManager.FindNextFocusableElement(FocusNavigationDirection.Right);
- return true;
- }
-
- if (!menu.IsOpened && element is MenuItem)
- {
- menu.UpdateMenuItemsFlyoutPlacement();
-
- if (args.VirtualKey == VirtualKey.Enter ||
- ((args.VirtualKey == VirtualKey.Down) && menu.CurrentFlyoutPlacement == FlyoutPlacementMode.Bottom) ||
- ((args.VirtualKey == VirtualKey.Up) && menu.CurrentFlyoutPlacement == FlyoutPlacementMode.Top) ||
- ((args.VirtualKey == VirtualKey.Left) && menu.CurrentFlyoutPlacement == FlyoutPlacementMode.Left) ||
- ((args.VirtualKey == VirtualKey.Right) && menu.CurrentFlyoutPlacement == FlyoutPlacementMode.Right))
- {
- menu.SelectedMenuItem.ShowMenu();
- return true;
- }
-
- if ((args.VirtualKey == VirtualKey.Left && orientation == Orientation.Horizontal) ||
- (args.VirtualKey == VirtualKey.Up && orientation == Orientation.Vertical))
- {
- GetNextMenuItem(menu, -1);
- return true;
- }
-
- if ((args.VirtualKey == VirtualKey.Right && orientation == Orientation.Horizontal) ||
- (args.VirtualKey == VirtualKey.Down && orientation == Orientation.Vertical))
- {
- GetNextMenuItem(menu, +1);
- return true;
- }
- }
-
- if ((menu.CurrentFlyoutPlacement == FlyoutPlacementMode.Left &&
- args.VirtualKey == VirtualKey.Right) ||
- (args.VirtualKey == VirtualKey.Left &&
- menu.CurrentFlyoutPlacement != FlyoutPlacementMode.Left))
- {
- if (element is MenuFlyoutItem)
- {
- menu.IsInTransitionState = true;
- menu.SelectedMenuItem.HideMenu();
- GetNextMenuItem(menu, -1).ShowMenu();
- return true;
- }
-
- if (element is MenuFlyoutSubItem menuFlyoutSubItem)
- {
- if (menuFlyoutSubItem.Parent is MenuItem && element == menu._lastFocusElement)
- {
- menu.IsInTransitionState = true;
- menu.SelectedMenuItem.HideMenu();
- GetNextMenuItem(menu, -1).ShowMenu();
- return true;
- }
- }
- }
-
- if ((args.VirtualKey == VirtualKey.Right &&
- menu.CurrentFlyoutPlacement != FlyoutPlacementMode.Left) ||
- (args.VirtualKey == VirtualKey.Left &&
- menu.CurrentFlyoutPlacement == FlyoutPlacementMode.Left))
- {
- if (element is MenuFlyoutItem)
- {
- menu.IsInTransitionState = true;
- menu.SelectedMenuItem.HideMenu();
- GetNextMenuItem(menu, +1).ShowMenu();
- return true;
- }
- }
-
- return false;
- }
-
- private static MenuItem GetNextMenuItem(Menu menu, int moveCount)
- {
- var currentMenuItemIndex = menu.Items.IndexOf(menu.SelectedMenuItem);
- var nextIndex = (currentMenuItemIndex + moveCount + menu.Items.Count) % menu.Items.Count;
- var nextItem = menu.Items.ElementAt(nextIndex) as MenuItem;
- nextItem?.Focus(FocusState.Keyboard);
- return nextItem;
- }
-
- private static string MapInputToGestureKey(VirtualKey key, bool menuHasFocus = false)
- {
- var isCtrlDown = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
- var isShiftDown = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);
- var isAltDown = Window.Current.CoreWindow.GetKeyState(VirtualKey.Menu).HasFlag(CoreVirtualKeyStates.Down) || menuHasFocus;
-
- if (!isCtrlDown && !isShiftDown && !isAltDown)
- {
- return null;
- }
-
- StringBuilder gestureKeyBuilder = new StringBuilder();
-
- if (isCtrlDown)
- {
- gestureKeyBuilder.Append(CtrlValue);
- gestureKeyBuilder.Append("+");
- }
-
- if (isShiftDown)
- {
- gestureKeyBuilder.Append(ShiftValue);
- gestureKeyBuilder.Append("+");
- }
-
- if (isAltDown)
- {
- gestureKeyBuilder.Append(AltValue);
- gestureKeyBuilder.Append("+");
- }
-
- if (key == VirtualKey.None)
- {
- gestureKeyBuilder.Remove(gestureKeyBuilder.Length - 1, 1);
- }
- else
- {
- gestureKeyBuilder.Append(key);
- }
-
- return gestureKeyBuilder.ToString();
- }
-
- internal bool UpdateMenuItemsFlyoutPlacement()
- {
- var placementMode = GetMenuFlyoutPlacementMode();
-
- if (placementMode == CurrentFlyoutPlacement)
- {
- return false;
- }
-
- CurrentFlyoutPlacement = placementMode;
-
- foreach (MenuItem menuItem in Items)
- {
- if (menuItem.MenuFlyout != null)
- {
- menuItem.MenuFlyout.Placement = CurrentFlyoutPlacement.Value;
- }
- }
-
- return true;
- }
-
- internal FlyoutPlacementMode GetMenuFlyoutPlacementMode()
- {
- var ttv = TransformToVisual(Window.Current.Content);
- var menuCoords = ttv.TransformPoint(new Point(0, 0));
-
- if (Orientation == Orientation.Horizontal)
- {
- var menuCenter = menuCoords.Y + (ActualHeight / 2);
-
- if (menuCenter <= Window.Current.Bounds.Height / 2)
- {
- return FlyoutPlacementMode.Bottom;
- }
- else
- {
- return FlyoutPlacementMode.Top;
- }
- }
- else
- {
- var menuCenter = menuCoords.X + (ActualWidth / 2);
-
- if (menuCenter <= Window.Current.Bounds.Width / 2)
- {
- return FlyoutPlacementMode.Right;
- }
- else
- {
- return FlyoutPlacementMode.Left;
- }
- }
- }
-
- private static void OrientationPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var menu = (Menu)d;
- if (menu._wrapPanel != null)
- {
- menu._wrapPanel.Orientation = menu.Orientation;
- }
-
- menu.UpdateMenuItemsFlyoutPlacement();
- }
-
- private static void RemoveElementFromCache(FrameworkElement descendant)
- {
- var value = descendant.GetValue(InputGestureTextProperty);
- if (value == null)
- {
- return;
- }
-
- var inputGestureText = value.ToString().ToUpper();
- if (!MenuItemInputGestureCache.ContainsKey(inputGestureText))
- {
- return;
- }
-
- var cachedMenuItem = MenuItemInputGestureCache[inputGestureText];
- if (cachedMenuItem == descendant)
- {
- MenuItemInputGestureCache.Remove(inputGestureText);
- }
- }
-
- private void ShowMenuItemsToolTips()
- {
- foreach (MenuItem item in Items)
- {
- item.ShowTooltip();
- }
- }
-
- private void UnderlineMenuItems()
- {
- foreach (MenuItem item in Items)
- {
- item.Underline();
- }
- }
-
- private void RemoveUnderlineMenuItems()
- {
- foreach (MenuItem item in Items)
- {
- item.RemoveUnderline();
- }
- }
-
- private void HideMenuItemsTooltips()
- {
- foreach (MenuItem item in Items)
- {
- item.HideTooltip();
- }
- }
-
- internal void CalculateBounds()
- {
- var ttv = TransformToVisual(Window.Current.Content);
- Point screenCoords = ttv.TransformPoint(new Point(0, 0));
- _bounds.X = screenCoords.X;
- _bounds.Y = screenCoords.Y;
- _bounds.Width = ActualWidth;
- _bounds.Height = ActualHeight;
-
- foreach (MenuItem item in Items)
- {
- item.CalculateBounds();
- }
- }
- }
-}
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.cs b/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.cs
deleted file mode 100644
index 93e6fd11e18..00000000000
--- a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Collections.Generic;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Controls.Primitives;
-
-namespace Microsoft.Toolkit.Uwp.UI.Controls
-{
- ///
- /// Menu Control defines a menu of choices for users to invoke.
- ///
- [Obsolete("This control will be removed in a future major release. Please use the MenuBar control from the WinUI Library instead.")]
- public partial class Menu : ItemsControl
- {
- private WrapPanel _wrapPanel;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public Menu()
- {
- DefaultStyleKey = typeof(Menu);
- }
-
- // even if we have multiple menus in the same page we need only one cache because only one menu item will have certain short cut.
- private static readonly Dictionary MenuItemInputGestureCache = new Dictionary();
-
- ///
- /// Gets or sets the orientation of the Menu, Horizontal or vertical means that child controls will be added horizontally
- /// until the width of the panel can't fit more control then a new row is added to fit new horizontal added child controls,
- /// vertical means that child will be added vertically until the height of the panel is received then a new column is added
- ///
- public Orientation Orientation
- {
- get { return (Orientation)GetValue(OrientationProperty); }
- set { SetValue(OrientationProperty, value); }
- }
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty OrientationProperty =
- DependencyProperty.Register(
- nameof(Orientation),
- typeof(Orientation),
- typeof(Menu),
- new PropertyMetadata(Orientation.Horizontal, OrientationPropertyChanged));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty MenuFlyoutStyleProperty = DependencyProperty.Register(nameof(MenuFlyoutStyle), typeof(Style), typeof(Menu), new PropertyMetadata(default(Style)));
-
- ///
- /// Gets or sets the menu style for MenuItem
- ///
- public Style MenuFlyoutStyle
- {
- get { return (Style)GetValue(MenuFlyoutStyleProperty); }
- set { SetValue(MenuFlyoutStyleProperty, value); }
- }
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty TooltipStyleProperty = DependencyProperty.Register(nameof(TooltipStyle), typeof(Style), typeof(Menu), new PropertyMetadata(default(Style)));
-
- ///
- /// Gets or sets the tooltip styles for menu
- ///
- public Style TooltipStyle
- {
- get { return (Style)GetValue(TooltipStyleProperty); }
- set { SetValue(TooltipStyleProperty, value); }
- }
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty TooltipPlacementProperty = DependencyProperty.Register(nameof(TooltipPlacement), typeof(PlacementMode), typeof(Menu), new PropertyMetadata(default(PlacementMode)));
-
- ///
- /// Gets or sets the tooltip placement on menu
- ///
- public PlacementMode TooltipPlacement
- {
- get { return (PlacementMode)GetValue(TooltipPlacementProperty); }
- set { SetValue(TooltipPlacementProperty, value); }
- }
-
- ///
- /// Gets the current selected menu header item
- ///
- public MenuItem SelectedMenuItem { get; internal set; }
-
- ///
- /// Gets a value indicating whether the menu is opened or not
- ///
- public bool IsOpened { get; internal set; }
-
- ///
- /// Gets or sets a value indicating whether the menu is in transition state between menu closing state and menu opened state.
- ///
- internal bool IsInTransitionState { get; set; }
-
- ///
- protected override void OnApplyTemplate()
- {
- Loaded -= Menu_Loaded;
- Unloaded -= Menu_Unloaded;
-
- Loaded += Menu_Loaded;
- Unloaded += Menu_Unloaded;
-
- base.OnApplyTemplate();
- }
-
- ///
- protected override bool IsItemItsOwnContainerOverride(object item)
- {
- return item is MenuItem;
- }
-
- ///
- protected override DependencyObject GetContainerForItemOverride()
- {
- return new MenuItem();
- }
- }
-}
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.xaml
deleted file mode 100644
index 221644775c8..00000000000
--- a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.xaml
+++ /dev/null
@@ -1,252 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/MenuItem.cs b/Microsoft.Toolkit.Uwp.UI.Controls/Menu/MenuItem.cs
deleted file mode 100644
index 684fece2370..00000000000
--- a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/MenuItem.cs
+++ /dev/null
@@ -1,531 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Toolkit.Uwp.UI.Extensions;
-using Windows.Foundation;
-using Windows.Foundation.Collections;
-using Windows.Foundation.Metadata;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Controls.Primitives;
-using Windows.UI.Xaml.Documents;
-using Windows.UI.Xaml.Input;
-using Windows.UI.Xaml.Media;
-
-namespace Microsoft.Toolkit.Uwp.UI.Controls
-{
- ///
- /// Menu Item is the items main container for Class Menu control
- ///
- [Obsolete("This control will be removed in a future major release. Please use the MenuBar control from the WinUI Library instead.")]
- public class MenuItem : HeaderedItemsControl
- {
- private const string FlyoutButtonName = "FlyoutButton";
- private const char UnderlineCharacter = '^';
- private readonly bool _isAccessKeySupported = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 3);
- private readonly bool _isTextTextDecorationsSupported = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 4);
- private Menu _parentMenu;
- private bool _isOpened;
- private bool _menuFlyoutRepositioned;
- private bool _menuFlyoutPlacementChanged;
- private string _originalHeader;
- private bool _isInternalHeaderUpdate;
-
- internal MenuFlyout MenuFlyout { get; set; }
-
- internal Button FlyoutButton { get; private set; }
-
- private Rect _bounds;
-
- private object InternalHeader
- {
- set
- {
- _isInternalHeaderUpdate = true;
- Header = value;
- _isInternalHeaderUpdate = false;
- }
- }
-
- ///
- /// Gets a value indicating whether the menu is opened or not
- ///
- public bool IsOpened
- {
- get
- {
- return _isOpened;
- }
-
- private set
- {
- _parentMenu.IsOpened = _isOpened = value;
- }
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public MenuItem()
- {
- DefaultStyleKey = typeof(MenuItem);
- IsFocusEngagementEnabled = true;
- }
-
- internal bool ContainsPoint(Point point)
- {
- return _bounds.Contains(point);
- }
-
- ///
- /// This method is used to hide the menu for current item
- ///
- public void HideMenu()
- {
- MenuFlyout?.Hide();
- }
-
- ///
- protected override void OnApplyTemplate()
- {
- FlyoutButton = GetTemplateChild(FlyoutButtonName) as Button;
- _parentMenu = this.FindParent