One of our customers has reported that when they click a MenuFlyout item that the event does not occur. At first I didn't believe it, then he sent a video. Then we managed to reproduce the problem on a Virtual Machine installation of Windows 10 1703 and 1709.
The scenario is when the MenuFlyout is built dynamically in code. MenuFlyouts defined in XAML work just fine.
This event creates a MenuFlyout and displays it when the button is clicked. When used on a real system (at least most systems) the menu works fine. Install it on a VM (Hyper-V Windows 1709) and either use it from the VM console or RDP. The MenuItem does not seem to call the event when clicked. It displays the items as defined and clears the menu from the screen when an item is clicked. No code in the event appears to run.
The customer who reported the issue however is not using a VM. His system is a HP-Envy PC h8-1437c. Has the same exact symptoms as we see on a VM. I do have a full sample project that can be supplied which reproduces the issue. when run on a VM but not when run on a local system.
******* XAML Declaration *************
<FlyoutBase.AttachedFlyout>
<MenuFlyout x:Name="DynamicMenuFlyout" />
</FlyoutBase.AttachedFlyout>
*******************************************
private void btnDynamic_Tapped(object sender, TappedRoutedEventArgs e)
{
DynamicMenuFlyout.Items.Clear();
MenuFlyoutItem dynamic1 = new MenuFlyoutItem();
dynamic1.Tapped += DynamicItem1_Tapped;
dynamic1.Text = "Dynamic Item 1";
DynamicMenuFlyout.Items.Add(dynamic1);
MenuFlyoutItem dynamic2 = new MenuFlyoutItem();
dynamic2.Tapped += DynamicItem2_Tapped;
dynamic2.Text = "Dynamic Item 2";
DynamicMenuFlyout.Items.Add(dynamic2);
MenuFlyoutItem dynamic3= new MenuFlyoutItem();
dynamic3.Tapped += DynamicItem3_Tapped;
dynamic3.Text = "Dynamic Item 3";
DynamicMenuFlyout.Items.Add(dynamic3);
DynamicMenuFlyout.Placement = Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode.Bottom;
DynamicMenuFlyout.ShowAt(DynamicMenuButton);
}
private void DynamicItem3_Tapped(object sender, TappedRoutedEventArgs e)
{
TextLog.Text += "Dynamic Item 3 clicked.\r\n";
}
private void DynamicItem2_Tapped(object sender, TappedRoutedEventArgs e)
{
TextLog.Text += "Dynamic Item 2 clicked.\r\n";
}
private void DynamicItem1_Tapped(object sender, TappedRoutedEventArgs e)
{
TextLog.Text += "Dynamic Item 1 clicked.\r\n";
}