My products page only shows \'Product Name\' and \'Quantity\', quantity isdisplayed/ binded to the picker.
For test purposes to get this working there is only 2 products
It looks like you have properly implemented INotifyPropertyChanged
on your ProductModel
, but now you need to subscribe to it in the constructor of the ProductModel
class.
I have stubbed up a simple implementation of what it is that you are looking for (I excluded the rest of your code so that it would be easier to digest)
public class ProductModel : INotifyPropertyChanged {
//Event
public event PropertyChangedEventHandler PropertyChanged;
//Fields
private string _ProductName;
private int _Quantity;
//Properties
public int Quantity {
get { return _Quantity; }
set {
_Quantity = value;
OnPropertyChanged();
}
}
public string ProductName {
get { return _ProductName; }
set {
_ProductName = value;
OnPropertyChanged();
}
}
//Constructor
public ProductModel() {
//Subscription
this.PropertyChanged += OnPropertyChanged;
}
//OnPropertyChanged
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) {
if (e.PropertyName == nameof(Quantity)) {
//Do anything that needs doing when the Quantity changes here...
}
}
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
Let me know if this gets you going