Is there a difference between System.Windows.Clipboard and System.Windows.Forms.Clipboard?
The documentation for the System.Windows.Forms version specifically states that to store an object on the clipboard it has to be serializable and your app has to have the STA model, but the documentation for the System.Windows version doesn't list either as a requirement. Is it? Why have two classes? What's the difference?
In case it matters, our app is WPF and yes I know the former is for WPF and the latter for Windows.Forms... but why? Why not just always use the System.Windows version even with forms-based apps considering it's just a reference and is less restrictive in its use, and an object is just an object in .NET.
Simple: System.Windows.Clipboard
(in PresentationCore.dll) is intended for use with WPF, while System.Windows.Forms.Clipboard
(in System.Windows.Forms.dll) is meant for Windows Forms.
You'll often come across seemingly identical classes in both assemblies; this is because WPF and WinForms are based on sufficiently different systems that many framework APIs have to be implemented differently. I haven't really worked with the system clipboard myself, but my guess is that it has something to do with WinForms' relative proximity to the low-level Win32 APIs. I wouldn't be certain, though.
Since you're working with WPF, you should use System.Windows.Clipboard
, since ostensibly the implementation is different for WPF than for WinForms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With