1
votes

I have an <Entry> in xaml, and I want to get that value the user types.

<Entry x:name="enteredInput>

The file with that <Entry> is in startingPage.xaml with a code behind class startingPage.xaml.cs.

Then I would like to transfer that value in the <Label> element of a different xaml, MainPage.xaml.

1
in your code behind, just pass the value of enteredInput.Text to your 2nd page and assign it to a LabelJason

1 Answers

4
votes

In your second page, add another constructor with string parameter. For ex, If your page name is StartingPage.xaml, then add another constructor like below. Inside, assign the incoming value to your label.

public StartingPage(string entryTextFromStartingPage)
    {
        InitializeComponent();
        lblEntryTextDisplay.Text = entryTextFromStartingPage;
    }

From the StartingPage.xaml.cs, add the below code in a button click or any event that you are calling the Main page,

Navigation.PushAsync(new MainPage(enteredInput.Text);