如何在WPF c#中的MDI控件中单击按钮时从另一个用户控件打开用户控件 [英] How to Open a User control from another user control on button click in MDI control in WPF c#

查看:253
本文介绍了如何在WPF c#中的MDI控件中单击按钮时从另一个用户控件打开用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我想点击另一个用户控件上的按钮打开用户控件。



请帮忙并提出建议。

Hello

I want to open a user control on click of a button which is on another user control.

please help and suggest.

推荐答案

控件不应该这样做,除非新控件完全在控件中打开它。

通常情况并非如此:两个控件都在一个表单中,并且不应该知道彼此的存在。在这种情况下,带按钮的控件(称为Child1)表示表单处理的事件,导致表单创建一个新控件(称为Child2)并将其添加到Controls集合。



这比听起来简单:在两者之间传递信息两种形式,第3部分:儿童到儿童 [ ^ ]几乎涵盖了表单,但是表单中的控件的原则(甚至代码)是相同的。
The control should not do it, unless the new control is fully within the control opening it.
Normally, this is not the case: both controls are within a form, and should not know of the existence of each other. In this case, the control with the button (call it Child1) signals an event which the form handles, causing the form to create a new control (call it Child2) and add it to the Controls collection.

It's simpler than it sounds: Transferring information between two forms, Part 3: Child to Child[^] covers it pretty much for forms, but the principles (and even the code) is the same for controls within a form.


这篇关于如何在WPF c#中的MDI控件中单击按钮时从另一个用户控件打开用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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