如何从嵌套UserControl调用另一个UserControl [英] How to call from Nested UserControl another UserControl
问题描述
Hello Everyone
我正在努力解决我的嵌套UserControl问题。
当我运行应用程序时,主窗口打开,主窗口内有一个按钮,当我点击该按钮时,它会调用一个UserControl(称为Applic)。
里面Applic UserControl是另一个名为PasswordScreen的嵌套UserControl。
在PasswordScreen中有一个名为Login的按钮,当我按下此按钮调用另一个UserControl(称为SwitchboardView)时什么都没招(这里是示例代码)
<前lang =c#> 私人 < span class =code-keyword> void btnLogin_Click( object sender,RoutedEventArgs e)
{
Applic ap = new Applic();
SwitchboardView sbv = new SwitchboardView();
ap.MainGridApplic.Children.Add(sbv);
}
有人可以帮我解决这个问题,我一直在苦苦挣扎解决这个问题,但我无法解决这个问题。
提前致谢...
亲切的问候
Roni
使用冒泡事件。因此事件在主窗口中处理。
Hello Everyone
I'm struggling to solve the problem with my nested UserControl.
When I run the application the main window opens, inside the main window is a button, when I click that button it calls up a UserControl (called Applic).
Inside the Applic UserControl is another nested UserControl called PasswordScreen.
Within the PasswordScreen there is a button called Login, when I press this button to call another UserControl (called SwitchboardView) it is not firing nothing (here is the sample code)
private void btnLogin_Click(object sender, RoutedEventArgs e)
{
Applic ap = new Applic();
SwitchboardView sbv = new SwitchboardView();
ap.MainGridApplic.Children.Add(sbv);
}
Could someone please help me solve this problem, I have been struggling for a long time to solve this problem but I just can't get it around.
Thanks in advance...
Kind regards
Roni
Hi,
Use the bubbling event.So that the events are handled in the main window.
这篇关于如何从嵌套UserControl调用另一个UserControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!