I need to create a dynamic forms in WPF. For example, say I need to allow the user to create a family tree with information about each of the people and each person will have infomation about their occupation.
class Person
{
int age;
int dateOfBirth;
List<Job> jobList = new List<Job>();
}
class Job
{
string title;
int salary;
}
This program needs to be able to have fields that will allow data entry of all the members in the class, including multiple jobs. I would like the forms data to (possibly) coded in XAML, where if they click the button "Add Person" it will expand another person entry box to allow the user to add information about the person. This is the same as "Add Job" but the jobs are only added under that person.
(Note that the end result of this will be a tree data structure that contains all the people and their children)
How would I go about doing this in WPF using the MVVM pattern? Before I learned the MVVM pattern, I had used code behind and created dynamic view using c# to code the XAML view and added it dynamically as child elements. But I don't think that is the best way to do this since it seems too tedious.
I'm new to the MVVM pattern so some small code snippets of how I would do this (using databinding?) would be very helpful.
I made a quick example coded in XAML of how the form might look like:
