How can I use data binding in WPF to create a new user control for each element in a list?

Posted by Joel on Stack Overflow See other posts from Stack Overflow or by Joel
Published on 2010-05-30T21:10:06Z Indexed on 2010/05/30 21:12 UTC
Read the original article Hit count: 387

I have a list of objects. For each item in the list, I want to create a new user control bound to that item. From what I've read, doing this programmatically is bad practice with WPF (as well as less than straightforward), so I should use data binding as a solution instead. The problem is, I can't figure out how to do this. I don't know the contents of the list (just the type) at compile-time, so I can't create and bind with XAML for each element. Google and MSDN don't seem to have any answers, so maybe I'm thinking about this the wrong way? What do I need to do?

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf