IWin32Window在WPF中

Pac*_*man 10 wpf winforms

我有一个excel AddIn,它暴露了IWin32Window作为它的主UI.我想显示一个WPF窗口,它使用它作为它的父级.

我该怎么做呢?

Ree*_*sey 8

您可以使用WindowInteropHelper来适当地为WPF窗口设置父级:

var helper = new WindowInteropHelper(theWpfWindow);
helper.Owner = win32Window.Handle;

theWpfWindow.Show(); // This is now parented appropriately
Run Code Online (Sandbox Code Playgroud)