Forum Xamarin.Forms

How to bind the logged in `player data` retrieved from database to populate in Register.xaml view.

In my Xamarin Forms app, how to bind the logged in player data retrieved from database to populate in Register.xaml view. This should be done on OnProfilePicClicked method

Register.xaml

<ContentPage.Content>







</ContentPage.Content>

MainPage.xaml.cs class:

private async void OnProfilePicClicked(object sender, EventArgs e)
{
//Navigate to Register screen with player data loaded:
var emailText = emailEntry.Text;
await Navigation.PushAsync(new Register(){});
List details = (from x in conn.Table() where x.Email == emailText select x).ToList();
if (details!= null)
{
// found the record here, but how to pass to view...

            PlayerDetails playerDetails = new PlayerDetails();
            playerDetails.FullName = details[0].FullName;
            playerDetails.Mobile = details[0].Mobile;
            playerDetails.SoccerPosition = details[0].SoccerPosition;
        }

    }

**PlayerDetails model class : **

string fullname;
string mobile;
string soccerposition;

    public PlayerDetails()
    {

    }

    public string FullName
    {
        set
        {
            if (fullname != value)
            {
                fullname = value;

                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("FullName"));
                }
            }
        }
        get
        {
            return fullname;
        }
    }

    public string Mobile
    {
        set
        {
            if (mobile != value)
            {
                mobile = value;

                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("Mobile"));
                }
            }
        }
        get
        {
            return mobile;
        }

    }

    public string SoccerPosition
    {
        set
        {
            if (soccerposition != value)
            {
                soccerposition = value;

                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("SoccerPosition"));
                }
            }
        }
        get
        {
            return soccerposition;
        }
    }

Answers

  • coolmindscoolminds Member ✭✭

    Posting the Register.xaml as it was not properly saved first time...

    <ContentPage.Content>












    </ContentPage.Content>

  • Sumit_SharmaSumit_Sharma USMember ✭✭✭

    Posting the Register.xaml as it was not properly saved first time...

    Not this time either, upload sample repo.

Sign In or Register to comment.