WindowsFormsHost invalid theme in WPF Application (.Net 3.5)
-
Dear Friends. I've making a wpf application. in a part of my program, I need some "windows forms" controls. I use WindowsFormsHost for using that controls. it work correctly, but the theme of controls (in windowsformshost) is windows classic. but I using Windows Aero (Windows 7). Here is an Image of my Problem: http://ghiasi.net/wpf.jpg[^] How can i correct the theme of Windows Forms Controls in WPF Application?
Regards. Mehdi Ghiasi
-
Dear Friends. I've making a wpf application. in a part of my program, I need some "windows forms" controls. I use WindowsFormsHost for using that controls. it work correctly, but the theme of controls (in windowsformshost) is windows classic. but I using Windows Aero (Windows 7). Here is an Image of my Problem: http://ghiasi.net/wpf.jpg[^] How can i correct the theme of Windows Forms Controls in WPF Application?
Regards. Mehdi Ghiasi
Windows Forms controls use a different method of rendering to WPF (they use GDI+). If you want the forms to have the theme, you'll either have to invest in a 3rd party control that does this or write your own theme management. Alternatively, you could use native WPF controls; for instance the colour drop down will be easily achieved by setting the display template for the control to show a coloured rectangle with a textblock beside it. The numeric spin control is included in a MS sample here[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
Dear Friends. I've making a wpf application. in a part of my program, I need some "windows forms" controls. I use WindowsFormsHost for using that controls. it work correctly, but the theme of controls (in windowsformshost) is windows classic. but I using Windows Aero (Windows 7). Here is an Image of my Problem: http://ghiasi.net/wpf.jpg[^] How can i correct the theme of Windows Forms Controls in WPF Application?
Regards. Mehdi Ghiasi
just call "System.Windows.Forms.Application.EnableVisualStyles();" in the constructor of your Window and it will fix it.
-
just call "System.Windows.Forms.Application.EnableVisualStyles();" in the constructor of your Window and it will fix it.
Thanks a lot!!!!!!!! ;)
Regards. Mehdi Ghiasi
-
Thanks a lot!!!!!!!! ;)
Regards. Mehdi Ghiasi
I thought you might like that answer better than the other guy's :) (no offence to the other guy)