I’m working with WPF and the MVVM pattern and I need to append elements to the window from the ViewModel. The scenario is: the user will have a collection of textbox simmulating fields of a table to insert products, and there’ll be a button to add more rows. My problem is just to create a way to make this button works. How can I do that ?
Is there a better way to solve a problem like this ? Needing to add many entities at once adding rows to a table ?
Thanks in advance for your aid.
Use an ObservableCollection in your view model bound to an ItemsControl. On the button click event add a new object to the collection. The UI will be notified that another object has been added to the collection and render the new row.