如何从 WPF 控件引用父窗体 [英] how to reference the parent form from the WPF control

查看:32
本文介绍了如何从 WPF 控件引用父窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 elementhost 在 Windows 窗体中托管 WPF 用户控件.我想知道如何在 WPF 控件中引用父表单.

I am using elementhost to host the WPF user control within a windows form. I want to know how to reference the parent form within WPF control.

推荐答案

为什么不以编程方式创建这种关系?即,当您将 WPF 用户控件添加到元素宿主中时,将用户控件的 Tag 属性设置为元素宿主实例.

Why not create this relationship programmatically? i.e. when you add your WPF user control into an element host, set the Tag property of the user control to the element host instance.

科林 E.

这篇关于如何从 WPF 控件引用父窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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