How to call from Nested UserControl another UserControl
-
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
-
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
You have already posted this in QA[^]. You've been here long enough to know our opinion of reposts. :suss:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
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 Roni, I created a WPF with nested controls and its working fine, what i did was Created 4 UserControls naming - UC1, UC2, UC3, UC4 As per the scenario stated in the question a UserControl is nested in another The code is as below :- UC1 XAML:- UC1 CODE BEHIND: private void Button_Click(object sender, RoutedEventArgs e) { this.MainGrid.Children.Clear(); this.MainGrid.Children.Add(new UC2()); } UC2 XAML:- UC2 CODE BEHIND: private void Button_Click(object sender, RoutedEventArgs e) { this.MainGrid.Children.Clear(); this.MainGrid.Children.Add(new UC3()); } Similary for UC3 and UC4 Try it let me if any problems