Ram Kishore
Ram Kishore

Reputation: 119

UWP RichEditBox RightClick->Paste is not triggering Paste event

When I press Ctrl + V inside the RichEditBox control, it's triggering the Paste event handler. But it doesn't trigger Paste event handler when do Right Click -> Paste. Instead it's pasting the copied image in the RichEditBox.

enter image description here enter image description here

<RichEditBox Name="EditorBox" Paste="EditorBox_Paste" />

I have to perform some operation in Paste event handler before the image is pasted.

How do I trigger Paste event handler, in Right Click -> Paste.

Upvotes: 0

Views: 198

Answers (1)

Faywang - MSFT
Faywang - MSFT

Reputation: 5868

By testing, if you set version 1903(build 18362) to the Target version, the Paste event can be triggered, but other versions can't. So you can try to use the latest version to see if the same issue occur.

Or you can also customize a menuflyout to replace the TextCommandBarFlyout which is used in RichEditBox and define it's click event. You need to notice the TextCommandBarFlyout only can be used above 1809.

<Page.Resources>
    <MenuFlyout x:Key="MYFLYOUT">
        <MenuFlyoutItem Text="Paste" Click="MenuFlyoutItem_Click"></MenuFlyoutItem>
    </MenuFlyout>

</Page.Resources>

<Grid>
    <RichEditBox Name="EditorBox" ContextFlyout="{StaticResource MYFLYOUT}" Paste="EditorBox_Paste" />
</Grid>

Upvotes: 1

Related Questions