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.


Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: