简体   繁体   English

UWP RichEditBox 右键单击->粘贴未触发粘贴事件

[英]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.当我在 RichEditBox 控件中按 Ctrl + V 时,它会触发粘贴事件处理程序。 But it doesn't trigger Paste event handler when do Right Click -> Paste.但是当右键单击->粘贴时它不会触发粘贴事件处理程序。 Instead it's pasting the copied image in the RichEditBox.相反,它将复制的图像粘贴到 RichEditBox 中。

在此处输入图像描述 在此处输入图像描述

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

I have to perform some operation in Paste event handler before the image is pasted.在粘贴图像之前,我必须在 Paste 事件处理程序中执行一些操作。

How do I trigger Paste event handler, in Right Click -> Paste.如何在右键单击-> 粘贴中触发粘贴事件处理程序。

By testing, if you set version 1903(build 18362) to the Target version, the Paste event can be triggered, but other versions can't.经测试,如果将版本 1903(build 18362) 设置为 Target 版本,可以触发 Paste 事件,但其他版本不能。 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.或者您也可以自定义一个 menuflyout 来替换 RichEditBox 中使用的 TextCommandBarFlyout 并定义它的点击事件。 You need to notice the TextCommandBarFlyout only can be used above 1809.您需要注意 TextCommandBarFlyout 只能在 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM