1

Possible Duplicate:
How can I convert 'System.Windows.Input.Key' to 'System.Windows.Forms.Keys'?

I have a WPF control that has object of type System.Windows.Input.KeyEventArgs. The control needs to pass that object to a method that expects a System.Windows.Forms.KeyEventArgs.

Is there a built-in adapter (see http://en.wikipedia.org/wiki/Adapter_pattern) in the .Net Windows Forms Integration classes to do that? Or do I have to code the adapter (including a huge switch case to map each value of System.Windows.Input.Key to the corresponding value in System.Windows.Forms.Keys)?

Community
  • 1
  • 1
Sylvain
  • 19,099
  • 23
  • 96
  • 145
  • 2
    Possible duplicate: http://stackoverflow.com/questions/1153009/how-can-i-convert-system-windows-input-key-to-system-windows-forms-keys – as-cii Mar 04 '11 at 21:05
  • @AS-CII: That link answers a part of my question and addresses the `Input.Key` to `Forms.Keys` mapping. But it does not address all the things that must be adapted. For instance, if the method that takes a `Forms.KeyEventArgs` sets the `Handeled` property to True, a good adapter would affect that same property on the adapted `Input.KeyEventArgs` object. – Sylvain Mar 04 '11 at 21:19
  • You should have used this info to edit your question. Claiming that you need help with assigning a bool property named Handled from a bool property that has the same name and description doesn't get you an answer. – Hans Passant Mar 04 '11 at 21:48
  • @Hans: I'm looking for an adaptor to wrap an Input.KeyEventArgs and expose it at Forms.KeyEventArgs. "Adapting" and "converting" are two very different things (see http://en.wikipedia.org/wiki/Adapter_pattern). An adaptor is an active object that forwards all calls to the adapted object. If there is no such thing in .Net, then the answer to my question is: No there is no such adapter in .Net, you have to build your own. – Sylvain Mar 04 '11 at 22:03

0 Answers0