Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Data Binding and INotifyPropertyChanged

$
0
0

I'm currently making an app using Xamarin Forms. This app will first call a REST service to retrieve the data and display them then store those data into a SQLite Database. I have an update button where if I click on it, it will prompt the REST service once again to retrieve newer data and replace the old data while the app is running. I have tried to implement the INotifyPropertyChanged but the value just wont' change for me. Am I missing anything with my code below? Thanks!

Vitals Object:

public class Vitals
{
    public string Height { get; set; }
    public string ID { get; set; }
    public string Weight { get; set; }
}

Update Method:

async void OnUpdate(object sender, EventArgs e)
    {
        string tempUser = globalPatient.Username;
        string tempPin = globalPatient.PIN;
        patUpdate = patientManager.GetPatientByUsername (tempUser, tempPin).Result;
        App.PatientDB.DeletePatient(tempID);
        App.PatientDB.AddNewPatient (patUpdate, tempPin);
        DisplayAlert ("Updated", "Your information has been updated!", "OK");
    }

VitalsViewModal:

`public class VitalsViewModel: INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

public VitalsViewModel (Patient patient)
{
    vitals = patient.Vitals;

}
private List<Vitals> _vitals;

public List<Vitals> vitals { 
    get {return _vitals; }

    set {
        if (_vitals != value) {
            _vitals = value;
            OnPropertyChanged ("vitals");
        }
    }
}

protected virtual void OnPropertyChanged(string propertyName)
{
    if (PropertyChanged != null)
    {
        PropertyChanged(this,
            new PropertyChangedEventArgs(propertyName));
    }
}

}`


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>