I'm a big fan of WPF and WinForms Interop, so have often advised people to try the ElementHost when they want to do something graphically complex on a Windows Form. This useful little container allows you to create a WPF UserControl right there inside the WinForms project and then display those WPF graphics in a Windows Form.
One of the negative things about this in VS 2008 is that you always get a kind of error message inside the ElementHost at Design Time which reads "Unable to generate a preview". It's not really an error, but it is negative feedback.
Although this message is disconcerting at first, you soon get used to it, and the WPF UserControl will display nicely once you actually run the project.
I was hoping that VS 2010 would fix this issue and that you would be able to see the WPF content in the ElementHost right there on the Window at Design time. The good news is that you can. The bad news is that the pseudo-error has been replaced with a genuine error!
The error message is: "Type 'WindowsFormsIntegration.Design.HostedComponent' is not available in the target framework". This message appears whether you choose Version 3.5 or 4 of the .NET Framework for the project. I was particularly surprised that I still got the error with 3.5 apps. You wouldn't have thought that a problem with v4 would be a breaking change in the earlier Framework, but this seems to be the case.
Anyway, I did some searching and found the fix documented in the Microsoft .NET Framework 4 Beta 1 Readme. It requires an additional Reference which is tucked away in the Visual Studio 2010 sub-folder in the Program Files folder. The exact path in my installation is:
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\WindowsFormsIntegration.Design.dll
You have to use the 'Browse' Tab instead of the more usual .NET tab of course to find and add this dll. You may also see a further warning message regarding the use of this dll with earlier versions of the Framework. This indicates that if you have your Framework set to 3.5 you don't need this dll (because it is a Framework 4 requirement). However, I couldn't get ElementHost to work properly in either 3.5 or 4 mode before I added this Reference, so that all left me a little confused - but happy, because it now works as it should.
Having sorted that out, I can now see the WPF UserControl on the Windows Form at Design Time, as you can see from the screenshot below. This is much more useful because it is often necessary to tweak the layout of the UserControl or other settings to make it fit in with the layout of other Windows Forms controls on the Form. Now that I can see it at Design time, I don't have to keep running and re-running the project to see the effect of changes.
I hope that this requirement to add the reference will be fixed by the time the final version of VS 2010 ships, but in the meantime I'll not complain about the small amount of work needed to gain the additional benefit.
Don't forget that you should already have the standard:
References in place for this kind of Interop task.