views:

56

answers:

1

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?

A: 

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

karmicpuppet
Wow I am not familiar with those unmanaged code. I guess I have to look for something else
jiewmeng
Yeah, well, as said in the writeup: ".NET does not provide events, and does not listen to the clipboard changes, so, we have to deep into Win32 in order to archive the requirement." So I'm not sure if you have much of a choice. I'll be interested if there is a better solution though.
karmicpuppet