C#/WPF: Any event that triggers when any changes are made to clipboard?

柔情痞子 提交于 2019-12-11 04:28:56

问题


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?

UPDATE

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() );

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?


回答1:


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



来源:https://stackoverflow.com/questions/3836169/c-wpf-any-event-that-triggers-when-any-changes-are-made-to-clipboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!