Universal Windows Platform (UWP)
A Microsoft platform for building and publishing apps for Windows desktop devices.
2,987 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The MenuFlyout shows up perfectly upon right-clicking the ListView
<ListView Name="lvDeviceTiles"
ItemsSource="{x:Bind listDeviceItems}"
DataContext="{x:Bind}"
Margin="0">
<!--ContextFlyout shows up automatically after right-click-->
<ListView.ContextFlyout>
<MenuFlyout
x:Name="menuFlyoutContext"
Opening="menuFlyoutContext_Opening">
...
</MenuFlyout>
</ListView.ContextFlyout>
</ListView>
How can I show it in C# code?
I tried:
FlyoutBase.ShowAttachedFlyout(lvDeviceTiles);
lvDeviceTiles.ContextFlyout.ShowAt(lvDeviceTiles);
lvDeviceTiles.ContextFlyout.ShowAt(myButton);
None of them work.
Hello,
Welcome to Microsoft Q&A!
I have to say that you are in the right direction. To show the MenuFlyout control, you could just call FlyoutBase.ShowAt Method to do that. But please note that MenuFlyout control is derived from FlyoutBase. So you just need to call MenuFlyout.ShowAt method in your scenario.
Like this:
private void Button_Click(object sender, RoutedEventArgs e)
{
menuFlyoutContext.ShowAt(lvDeviceTiles);
}
Thank you!