简体   繁体   中英

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

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM