MVVM NotifyPropertyChanged NOT WORKING - not changing the ui

ALI ALHOWSWE 191 Reputation points
2021-01-16T04:56:16.067+00:00

Hello i am trying to make a cart when the user change the numbers of the item ui change but is it not working
here is my code :

 public ObservableCollection<ItemsPreview> itemPreview
        {
            get => _itemPreview;
            set
            {
                _itemPreview = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(_itemPreview)));
            }
        }
        readonly IList<ItemsPreview> source1;

        private ObservableCollection<ItemsPreview> _itemPreview;
 protected virtual void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

 public ICommand increazeNumber { get; set; }
        public ICommand DecrazeNumber { get; set; }
       public CartViewModel(string UserIp)
        {


            increazeNumber = new Command<ItemsPreview>(async items =>
            {
                int NewQuntity = 0;
                //check the stock fisrt
                NewQuntity = int.Parse(items.Qyt.ToString()) + 1;
                items.Qyt = NewQuntity;


            });

            DecrazeNumber = new Command<ItemsPreview>(async items =>
            {
                int NewQuntity = 0;
                //check the stock fisrt
                NewQuntity = int.Parse(items.Qyt.ToString()) - 1;
                items.Qyt = NewQuntity;


            });
        }
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,366 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.