posted on Saturday, February 18, 2006 2:31 PM
by
davidboschmans
Crossbow or Windows Forms and WPF Interop
Already heard of "Crossbow"? If not then you might want to check out the MSDN TV Episode on "Crossbow" - Windows Forms and Windows Presentation Foundation Interoperability.
Mike Henderlight introduces the "Crossbow" technology and describes how you can use it to build hybrid Windows Forms and Windows Presentation Foundation applications. The interop from a WPF application using Windows Forms controls is actally realized by referencing the System.Windows.Forms and WindowsFormsIntegration assemblies. Next you create a WindowsFormHost control that allows you to host a Windows Forms control as an element of a Windows Presentation Foundation page. Add a windows forms control (eg. a button) to the hostcontrol and add the hostcontrol to the WPF window. Running this shows a simple windows forms button displayed on a WPF window. All of this can also be done through XAML.
And of course hosting Windows Forms controls from a Windows Presentation Foundation is possible too. This is realized by using the ElementHost class. This class can be used to host a Windows Presentation Foundation (formerly code-named "Avalon") element.
The latest version of the WindowsFormsIntegration.dll to use is the one of the Cider drop CTP. From Mike's post you can learn why it's important to pick the right version of the WindowsFormsIntegration.dll.
There's also an article that's worth reading on Windows Presentation Foundation Interoperability in Dr. Dobb's.