@@ -71,6 +71,7 @@ public SidebarDisplayMode SidebarDisplayMode
7171 public delegate void SelectedTagChangedEventHandler ( object sender , SelectedTagChangedEventArgs e ) ;
7272
7373 public static event SelectedTagChangedEventHandler ? SelectedTagChanged ;
74+ public static event EventHandler < INavigationControlItem ? > ? RightClickedItemChanged ;
7475
7576 private readonly SectionType [ ] SectionOrder =
7677 new SectionType [ ]
@@ -663,12 +664,14 @@ public void UpdateTabControlMargin()
663664
664665 public async void HandleItemContextInvokedAsync ( object sender , ItemContextInvokedArgs args )
665666 {
666- if ( sender is not FrameworkElement sidebarItem ) return ;
667+ if ( sender is not FrameworkElement sidebarItem )
668+ return ;
667669
668670 if ( args . Item is not INavigationControlItem item )
669671 {
670672 // We are in the pane context requested path
671673 PaneFlyout . ShowAt ( sender as FrameworkElement , args . Position ) ;
674+
672675 return ;
673676 }
674677
@@ -688,20 +691,29 @@ public async void HandleItemContextInvokedAsync(object sender, ItemContextInvoke
688691 }
689692
690693 rightClickedItem = item ;
691- var itemContextMenuFlyout = new CommandBarFlyout { Placement = FlyoutPlacementMode . Full } ;
694+ RightClickedItemChanged ? . Invoke ( this , item ) ;
695+
696+ var itemContextMenuFlyout = new CommandBarFlyout ( )
697+ {
698+ Placement = FlyoutPlacementMode . Full
699+ } ;
700+
692701 itemContextMenuFlyout . Opening += ( sender , e ) => App . LastOpenedFlyout = sender as CommandBarFlyout ;
702+ itemContextMenuFlyout . Closed += ( sender , e ) => RightClickedItemChanged ? . Invoke ( this , null ) ;
693703
694704 var menuItems = GetLocationItemMenuItems ( item , itemContextMenuFlyout ) ;
695705 var ( _, secondaryElements ) = ItemModelListToContextFlyoutHelper . GetAppBarItemsFromModel ( menuItems ) ;
696706
697- secondaryElements . OfType < FrameworkElement > ( )
698- . ForEach ( i => i . MinWidth = Constants . UI . ContextMenuItemsMaxWidth ) ;
707+ secondaryElements
708+ . OfType < FrameworkElement > ( )
709+ . ForEach ( i => i . MinWidth = Constants . UI . ContextMenuItemsMaxWidth ) ;
710+
711+ secondaryElements . ForEach ( itemContextMenuFlyout . SecondaryCommands . Add ) ;
699712
700- secondaryElements . ForEach ( i => itemContextMenuFlyout . SecondaryCommands . Add ( i ) ) ;
701713 if ( item . MenuOptions . ShowShellItems )
702714 itemContextMenuFlyout . Opened += ItemContextMenuFlyout_Opened ;
703715
704- itemContextMenuFlyout . ShowAt ( sidebarItem , new FlyoutShowOptions { Position = args . Position } ) ;
716+ itemContextMenuFlyout . ShowAt ( sidebarItem , new ( ) { Position = args . Position } ) ;
705717 }
706718
707719 private async void ItemContextMenuFlyout_Opened ( object ? sender , object e )
0 commit comments