Forum General

help need

raddradd Member ✭✭

hello everyone, im new to xamarin. in the app that a developing, the mainpage contains two buttons that navigate to a popup page which contains a label a textbox and a picker. what i want is, when i click on one of the button it should change the label text and picker options in the popup page. ive spent a lot of hours trying to figure it out but nothing.
thank you in advance

Posts

  • WorldOfBastiWorldOfBasti Member ✭✭✭
    edited August 2020
    You can call your popup page like this:

    ```
    PopupNavigation.Instance.PushAsync(new yourPopup("yourMessage"));
    ```

    And your Popup in c# should look like this:

    ```
    public partial class yourPopup : PopupPage
    {
    public yourPopup(string message)
    {
    InitializeComponent();

    yourLabel.Text = message;
    }
    }
    ```

    Or you can use MVVM, or you make a second static label like this:
    ```
    public partial class yourPopup : PopupPage
    {
    public static _yourLabel;

    public yourPopup()
    {
    InitializeComponent();

    _yourLabel = this.FindByName<Label>("yourLabel");
    }
    }
    ```
    Then you can simply call yourPopup._yourLabel.Text = "yourMessage"; but be careful, this can produce an error if the popup is closed..
  • raddradd Member ✭✭

    thank you very much for the reply. i really appreciate it

    so currently the issue i am facing is,
    1. the main page has three button, which navigates to two different popup pages and a final page .
    2. when first button is clicked i would want it to navigate to the popup page assigned and at the same time change to label text in final page.
    3. when the second button is clicked same here, navigate to second popup page and change the label text in the final page.(the popup pages contain multiple pickers and textbox which are bound to the final page)
    4. when i click on the final page button if the second button was the last to be clicked i want to label the second button click changed to appear there.
    5. in the final page i have label1 to receive data from the picker in the popup and label2 are just titles that i want to change based on the label click.
    I would want to achieve that using mvvm
    @WorldOfBasti

  • WorldOfBastiWorldOfBasti Member ✭✭✭
    edited August 2020

    You can use getter and setter for this, but I can't help you with MVVM. I haven't done so much with it yet, sorry.

Sign In or Register to comment.