I want to override the right-click menu in a RichTextBlock
or a TextBlock
, I have been searching for the solution and tried using RightTappedEvent
, but it did not fire when right tapped a chosen text, but it fired when I right tapped in elsewhere in the control.
Yes, you can use ContextFlyout
to change it.
You can add the ContextFlyout
to custom your menu.
The code shows how to add the custom menu.
<RichTextBlock HorizontalAlignment="Center" VerticalAlignment="Center">
<RichTextBlock.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem Text="1" />
<MenuFlyoutItem Text="2" />
</MenuFlyout>
</RichTextBlock.ContextFlyout>
<Paragraph>Welcome to my blog http://blog.lindexi.com I write some UWP blogs</Paragraph>
</RichTextBlock>
See UWP How to custom RichTextBlock right click menu
All code is in github