I reference this post WPF UserControl Reuse With MVVM because it’s similar, but not exactly what i’m hoping to achieve.
The user can retrieve multiple employees from a database based on input from the wpf app. The number of employees read in changes depending on the specific db query. Rather than putting the employees read in from the database in a datagrid, I have created a user control that represent an email with name, icon, role, etc.
The way I have done this – which I presume is wrong – is to store the read in data from the database in an observable collection eg. observablecollection employees
And for each employee in the collection there is a user control added to a stackpanel in code behind eg. employeeStackPanel.Children.Add(user control)
But I don’t quite know how to bind the user controls to the objects in the employees observable collection.