I am implementing a cart in Xamarin.Forms. On my page there are baskets ListViewwith data. Each cell contains a button for selecting the number of elements and the number. There is a total amount in the cart.
My problem is that the total amount is not updated when changing the choice of number. The calculation method is called the element of adding the position of the element. I know what I need to implement INotifyPropertyfor this, but I'm not sure how to do it.
I have a base view model that inherits INotifyPropertythat contains an event.
public class BaseViewModel : INotifyPropertyChanged
{
private double _price;
public double Price
{
get
{
return _price;
}
set
{
_price = value;
OnPropertyChanged("Price");}
}
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
View Model
public BaseViewModel()
{
App.Instance.ViewModel = this;
TempList = TempList ?? new ObservableCollection<cm_items>();
this.Title = AppResources.AppResource.Cart_menu_title;
this.Price = CartCell.price;
}
user4318551
source
share