UWP RichEditBox RightClick->粘贴未触发粘贴事件

时间:2019-11-08 07:38:53

标签: c# uwp

当我在RichEditBox控件中按Ctrl + V时,它将触发粘贴事件处理程序。但是在右键单击->粘贴时,它不会触发粘贴事件处理程序。而是将复制的图像粘贴到RichEditBox中。

enter image description here enter image description here

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

在粘贴图像之前,我必须在Paste事件处理程序中执行一些操作。

如何在右键->粘贴中触发粘贴事件处理程序。

1 个答案:

答案 0 :(得分:1)

通过测试,如果将版本1903(内部版本18362)设置为目标版本,则可以触发粘贴事件,而其他版本则不能。因此,您可以尝试使用最新版本来查看是否发生相同的问题。

或者,您也可以自定义menuflyout以替换RichEditBox中使用的TextCommandBarFlyout并定义其click事件。您需要注意TextCommandBarFlyout仅可在1809以上使用。

let imageToPass: UIImage?

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
   if segue.identifier == "identifier name here" {

       // Get the new view controller using segue.destination.
       if let destVC = segue.destination as? SecondViewController {
           // Pass the selected object to the new view controller.
           destVC.image = imageToPass
       }
   }
}