How to pass data between view controllers in Xamarin

后端 未结 2 1955
抹茶落季
抹茶落季 2021-01-22 03:33

I am trying to pass some data between my first and second ViewController. I already instantiated the second view controller like this:

Registration         


        
相关标签:
2条回答
  • 2021-01-22 03:57

    Try something based on this :

    SecondViewController controller = this.Storyboard.InstantiateViewController("SecondViewController") as SecondViewController;
    //Here you pass the data from the registerViewController to the secondViewController
    controller.email = registration.email;
    
    this.NavigationController.PushViewController(registration, true);
    

    Hope it helps

    0 讨论(0)
  • 2021-01-22 04:17

    try this out

      UIStoryboard board = UIStoryboard.FromName("Main", null);
      UIViewController ctrl = (UIViewController)board.InstantiateViewController("RegistrationViewController");
      ctrl.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;
      this.PresentViewController(ctrl, true, null);
    
    0 讨论(0)
提交回复
热议问题