Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. How to call from Nested UserControl another UserControl

How to call from Nested UserControl another UserControl

Scheduled Pinned Locked Moved WPF
helptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LAPEC
    wrote on last edited by
    #1

    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

    Richard DeemingR E 2 Replies Last reply
    0
    • L LAPEC

      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

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      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

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • L LAPEC

        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

        E Offline
        E Offline
        Elegantly Wasted
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups