Click here to Skip to main content
15,849,829 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello guys,
I'm using a WindowsFormsHost to hosting an external EXE into my WPF application.
If I host a WinForm application this working good.
The problem begin when I try to host a WPF EXE application. The application is loaded, but is visualized only the external border, with a transparent on black content.
The other part of the application is loaded only when I click on the upper border.

I'm going crazy...

Thanks all those who can help me..

Here the code.

WindowsFormsHost wfh = new WindowsFormsHost();
F.Panel panel1 = new F.Panel();

Grid MainGrid = new Grid();

TabItem Tab = new TabItem();
Tab.Content = MainGrid;

ProcessStartInfo psi = new ProcessStartInfo(@"c:\app\myWPFapp.exe");
Process p = Process.Start(psi);

for (int i = 0; i < 1000; i++)
           if (p.MainWindowHandle != IntPtr.Zero)

SetParent(p.MainWindowHandle, panel1.Handle);
ShowWindow(p.MainWindowHandle, SW_SHOWMAXIMIZED);


Sergey Alexandrovich Kryukov 22-Dec-14 10:48am    
I would advise to change the question title. "Host WPF EXE into WPF project" sounds perfect gibberish.
Project doesn't "host" anything in that sense; they are just the development artifacts.
And what you are trying to do doesn't seem to make any sense while showing all signs of technology abuse.
We can help you only if you explain what you really want to achieve and why.
Deodo 22-Dec-14 14:07pm    
Sorry for the title..I'm trying to do a launcher application that can launch and host other WPF applications.
Sergey Alexandrovich Kryukov 22-Dec-14 14:31pm    
It doesn't really make sense. Generally, "integrating" independent applications is a bad idea. Why?

Put your WPF stuff in a DLL. In fact, you should also do that for your WinForms application as someone has commented, what you are trying to do does not make sense. It is not how things are supposed to work.

You are not helping anybody be trying such suspicions hacks. The UI of multiple EXE should be independant.
Share this answer
Sergey Alexandrovich Kryukov 22-Dec-14 14:32pm    
Agree, a 5.
You should read MSDN help pages carefully...
An element that allows you to host a Windows Forms control on a WPF page.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900