简体   繁体   English

用户控件点击事件调用新的用户控件

[英]Usercontrol click event calling new usercontrol

I am making one student registration system in WPF, i have one very odd query regarding it that i have one window inside which there are two stackpanels and in both the stack panels usercontrol are added dynamically. 我正在WPF中建立一个学生注册系统,对此我有一个非常奇怪的查询:我有一个窗口,其中有两个堆栈面板,并且在两个堆栈面板中都动态添加了usercontrol。 Eg.Usercontrol 1 is added to Stackpanel1 for Window now these usercontrol-1 are generated dynamically lets say they are student names , now when i click one of the student names (usercontrol -1) it should get all the details of that particular student and call new usercontrol-2 and add as a child to stackpanel-2 in the window. 例如,将Usercontrol 1添加到Window的Stackpanel1中,现在动态生成了这些usercontrol-1,可以说它们是学生姓名,现在当我单击其中一个学生姓名(usercontrol -1)时,它应该获取该特定学生的所有详细信息,并且调用new usercontrol-2并作为子代添加到窗口中的stackpanel-2中。

I am able to handle the click event for usercontrol-1 for each and every student and also get their information and pass those information to usercontrol-2 now what i need is how do i add that usercontrol -2 to stackpanel-2 of window from by writing code inside usercontrol-1 OR is there any other method for doing the same. 我能够为每个学生处理usercontrol-1的click事件,还可以获得他们的信息并将这些信息传递给usercontrol-2,现在我需要的是如何将usercontrol -2添加到窗口的stackpanel-2中通过在usercontrol-1内编写代码,或者还有其他方法可以做到这一点。

Please help me regarding this , i am really stucked up !! 请对此帮助我,我真的很困!

From your description I got that you are handling usercontrol-1 click inside it. 根据您的描述,我知道您正在处理usercontrol-1,请在其中单击。 You can simply handle it's click event on the window level and place all code to add usercontrol-2 and initialize it there. 您可以在窗口级别上简单地处理它的click事件,然后放置所有代码以添加usercontrol-2并在那里进行初始化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM