开发者

Is it possible in WPF to have a Panel and be able to add UserControls to it (Similar to Windows Forms)?

开发者 https://www.devze.com 2022-12-27 06:01 出处:网络
I\'m going to be making a user control for person information, I will then populate a panel o开发者_Go百科f some sort with the ammount of people found (one user control for each person).

I'm going to be making a user control for person information, I will then populate a panel o开发者_Go百科f some sort with the ammount of people found (one user control for each person).

Can WPF handle this?


You can do this, but it is not necessarily the best option.

Instead of putting in controls per person, you can use an ItemTemplate that describes how to render a "Person". You can then just bind a (standard) ItemsControl, such as a ListBox or ListView to your collection of people directly, and WPF will handle wiring it up for you.

For details, I'd recommend reading up on Data Binding on MSDN, in particular, "Binding to Collections."

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号