WinformHost面板内的WPF窗口

问题描述:

我在使用winform主机的另一个WPF应用程序内显示WPF exe窗口。WinformHost面板内的WPF窗口

我在主应用程序中创建了一个面板,并将其设置为winformhost的子面板。

mHostingPanel = new System.Windows.Forms.Panel() 
      { 
       BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle 
      };     


      mWinformHost = new WindowsFormsHost(); 
      mWinformHost.Child = mHostingPanel; 

然后我启动其他窗口进程并将主机面板设置为父级。

WindowsAPI.SetParent(mProcess.MainWindowHandle, mHostingPanel.Handle); 

我的问题是,如果我启动应用程序,他们将呈现我的孩子WPF,其父母为一个winform panel.Will它是直接-X或面板的GDI上下文窗口?

此外,如果我在子WPF应用程序上设置Allowtransparency = True,UI不会显示在主机面板中。

+0

这是邪恶的,而不一定是坏的方式! – tolanj

+0

我不认为取得窗口的所有权将会影响wpf渲染。我会看看这个虽然:https://blogs.msdn.microsoft.com/oldnewthing/20130412-00/?p=4683/ – tolanj

+0

@tolanj:如果你阅读该博客条目,你不可能得出结论,这不一定是邪恶的。以非常**非常糟糕的方式。这个其他应用程序肯定不准备重新参与。如果是,它将是一个ActiveX控件。 – IInspectable

找到原因。其称为空域问题(当win32和WPF试图共享像素时),我不认为它可以通过任何框架API解决,因为微软否认它。 https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2644120-bring-back-the-hwndhost-isredirected-and-compositi

Mitigating AirSpace issues