Posted by: scipbe | February 21, 2008

Background color problem with WinForms and WPF interoperability

Some days ago I was examining the interoperability between Windows Forms and Windows Presentation Foundation (WPF). It seems to be quite easy to integrate WPF user controls in a WinForms form by creating an ElementHost (System.Windows.Forms.Integration) object. I really like this component because it makes it possible to integrate some powerful graphical features of WPF in current WinForms applications.

While trying several features I bumped into an annoying background color problem. It turns out that the background of the WPF user control becomes black when I try to create all objects in run-time and use SystemColors.Control as background color.

So this small article on my website provides a workaround to solve the background color problem of the ElementHost class. It also demonstrates how you can map properties between Windows Forms controls and WPF UI elements.


Leave a response

Your response:

Categories