WPF 中的 IWin32Window [英] IWin32Window in WPF

查看:50
本文介绍了WPF 中的 IWin32Window的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 excel 插件,它公开 IWin32Window 作为它的主 UI.我想显示一个 WPF 窗口,使用它作为它的父窗口.

I have an excel AddIn which exposes IWin32Window as it's main UI. I want to show a WPF window that uses this as it's parent.

我该怎么做?

推荐答案

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

You can use WindowInteropHelper to parent the WPF window appropriately:

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

theWpfWindow.Show(); // This is now parented appropriately

这篇关于WPF 中的 IWin32Window的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆