using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ComponentModel; using System.Windows.Input; using System.Collections.ObjectModel; namespace QuickMVVMSetup; public class MainVM : ChangeNotifier { private Person person; public Person TargetPerson { get { return person; } set { person = value; OnPropertyChanged(nameof(TargetPerson)); } } private ObservableCollection _persons; //only when added/or removed (not for internal property changes) public ObservableCollection Persons { get { return _persons; } set { _persons = value; } } public void AddPerson(object person) { Persons.Add(TargetPerson); // Adding to collection TargetPerson = new Person(); //Resetting it } //public ICommand CMDAdd { get; set; } public ICommand CMDAdd => new RelayCommand(AddPerson,null); public MainVM() { //CMDAdd = new AddCommand(this); //TargetPerson = new Person(); Persons = new ObservableCollection(); } }