I'm trying to hosting an exe on the WPF program by using WinfowsFormsHost and System.Windows.Forms.Panel.Here is the code:
public void AddPuttyPage(Process process)
{
var picPan = new System.Windows.Forms.Panel() {
Dock = System.Windows.Forms.DockStyle.Fill
};
var winform = new WindowsFormsHost
{
Child = picPan,
HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
VerticalAlignment = System.Windows.VerticalAlignment.Stretch
};
//Tabs are bind to the TabControl on a xaml
Tabs.Add(new TabItem { Header = "Tab1", Content = winform });
process.WaitForInputIdle();
SetParent(process.MainWindowHandle, picPan.Handle);
}
I want the System.Windows.Forms.Panel
fill the container so that the exe application fill the window. I set Dock = System.Windows.Forms.DockStyle.Fill
,But it doesn't work,the Panel still has default size 100*200.
So what should I do to let the Panel fill it's container?(Panel's container is WindowsFormsHost,and WindowsFormsHost is the content of the TabItem, so I want the panel fill the tabPage in fact)