如何在Silverlight 4中检测Ctrl + V? [英] How to detect Ctrl+V in Silverlight 4?

查看:110
本文介绍了如何在Silverlight 4中检测Ctrl + V?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Silverlight中检测 Ctrl + V 的最佳方法是什么?

What is the best way to detect Ctrl+V in Silverlight?

我想检测 Ctrl + V ,以访问剪贴板.

I want to detect Ctrl+V, to get access to the Clipboard.

推荐答案

编辑

要在Silverlight应用程序中全局捕获 CTRL + V 按键非常困难.事件从子元素开始,然后冒泡到父控件,因此仅在根UIElement上处理KeyDown无效.任何文本输入控件都将首先获取该事件并将其窒息(通过将事件args上的Handled设置为true.)我认为,如果您使用DOM桥并为Silverlight元素本身的浏览器KeyDown事件订阅了一个处理程序,则可能实际上能够首先使用它,甚至在任何Silverlight控件可以使用它之前就完全能够处理它.我认为这是拦截 CTRL + V 的最简单方法,但我尚未对其进行测试.

To capture the CTRL+V keypress globally in your silverlight application, is fraught with difficulty. Events start at the child elements and bubble down to the parent controls, so simply handling KeyDown on your root UIElement will not work. Any text input control will first get the event and smother it (by setting Handled to true on the event args.) I think that if you use the DOM bridge and subscribe a handler to the browser KeyDown event for the silverlight element itself that you may actually be able to get to it first, and even handle it completely before any silverlight controls can. I think that would be the easiest way to intercept CTRL+V, but I have not tested it.

原始答案

您应该使用 System.Windows.Clipboard 类.

  • GetText,用于从中检索文本 剪贴板
  • SetText,放置 剪贴板上的文字
  • 包含文本, 指示剪贴板是否 当前包含文本
  • GetText, which retrieves text from the clipboard
  • SetText, which places text on the clipboard
  • ContainsText, which indicates whether the clipboard currently contains text

这篇关于如何在Silverlight 4中检测Ctrl + V?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆