views:

128

answers:

3

In my WPF Project I have a WPF Window. I want to use Sticky Windows Solution in my WPF Project. The library wants only one parameter: the System.Windows.Forms.Form object.

Does it exist any way to obtain a Form object starting from a WPF Window object?

+1  A: 

No, it's not possible. A WPF Window has no inheritance relation with a Windows Forms Form. However it would probably be possible to adapt the code from the library to mentioned so that it works with WPF...

Thomas Levesque
I converted all reference to Form in my interface IFormAdapter. Now I have two implementation: WinFormAdapter and WpfFormAdapter.
Ricibald
A: 

While it's not possible, the article and code does present enough information for you to create a WPF version.

Pete OHanlon
+1  A: 

The approach others have mentioned of refactoring Sticky Windows Solution to support WPF forms sounds like your best option. If you really want to treat a WPF form as a Windows Form, maybe the below will help:

Would this work?

  • Host your WPF form in an ElementHost control. (ElementHost enables a WPF element to be treated as a Windows Form control.)
  • Create a simple Windows Form containing only this ElementHost control.
  • Use a reference to this Windows Form in your Sticky Windows Solution.
Ben Gribaudo