C#/ WPF:对剪贴板进行任何更改时触发的任何事件? [英] C#/WPF: Any event that triggers when any changes are made to clipboard?

查看:54
本文介绍了C#/ WPF:对剪贴板进行任何更改时触发的任何事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要的最终结果是实际上检测剪贴板是否包含任何图像,如果是,则设置一个图像控件以显示该图像。我在想如果剪贴板包含图像,我将需要一种监控剪贴板的方法。我该如何实现?我认为可能没有此类事件,所以也许我要定期检查剪贴板以查看是否包含任何图像(如果显示的话)?

The final outcome I want is actually detect if the clipboard contains any Image, if so then set a Image control to display that image. I am thinking I will need a way to monitor the clipboard if it contains an Image. How can I achieve this? I am thinking probably theres no such event so maybe i check the clipboard at regular intervals to see if it contains any image if so display it? Will it be very inefficient?

更新

我想知道是否一样吗?剪贴板中包含图像时启用/禁用我的按钮的机制可以在这里使用吗?我正在使用 MVVM Foundation

I am wondering if the same mechanism that enables/disables my button when the clipboard contains an image can come into use here? I am using MVVM Foundation.

GetImageFromClipboard = new RelayCommand(() => ImageData = Clipboard.GetImage(), () => Clipboard.ContainsImage() );

因为它正确启用/禁用了绑定到此按钮的按钮。我可以做类似CanExecute更改时的操作,如果有图像,则显示它吗?

because it enables/disables my Button bound to that correctly. Can i do something like when the CanExecute changes, If theres an image, display it?

推荐答案

以下内容可能对您有帮助出: http://blogs.microsoft.co.il/blogs/tamir/archive/2008/01/21/clipboard-and-wpf-as-hooks-and-imagesources.aspx

Here's probably something that could help you out: http://blogs.microsoft.co.il/blogs/tamir/archive/2008/01/21/clipboard-and-wpf-as-hooks-and-imagesources.aspx

这篇关于C#/ WPF:对剪贴板进行任何更改时触发的任何事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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