Xamarin pass data to another page

前端 未结 1 1950
情深已故
情深已故 2021-01-15 21:41

I want to pass the entered name to page 1. I handled the variable, which means that when you enter your name and click the button it will be put in variable valueName. But

相关标签:
1条回答
  • 2021-01-15 22:21

    Pages are just classes. You can pass parameters to them using the constructor, public properties, public methods, etc

    For example, to pass via the constructor

    private void Button_Clicked(object sender, EventArgs e)
    {
        string valueName = name.Text;
        Detail = new NavigationPage(new Page1(valuename));
        IsPresented = false;       
    }
    

    in Page1, modify the constructor to accept a parameter

    string _name;
    
    public Page1 (string name)
    {
        InitializeComponent ();
    
        _name = name;
    }
    
    0 讨论(0)
提交回复
热议问题