0

I have a main window with grid and have to fill the grid with a user control(basically an expander with list). The number of instances of UC I need to create is dynamic. The viewsource that I need to bind is also generated on the fly. I need to bind it so that I can do some processing based on the items the user selects in the dynamic generated UC's. I could achieve this in code behind. But I was wondering how to do the same applying MVVM.

Any help is appreciated.

Thanks, BUB

BUB
  • 73
  • 1
  • 8

1 Answers1

0

Create a property on you parent ViewModel with a list of viewmodels(observablecollection) that you need to bind controls to!

On GUI place an ItemPresenter, use Ites and bind it to the Property that you just created.

Add new viewmodel instances on the list(property)

And GUI will draw the Controls(DataTemplats) Dynamiclly

Burim Hajrizaj
  • 383
  • 4
  • 14
  • Burim, thanks for the response. I am new to WPF can you point me to some example that will help me understand more. – BUB May 17 '15 at 17:24
  • Found a good article at http://stackoverflow.com/questions/2913854/wpf-dynamic-layout-with-itemscontrol-and-grid. – BUB May 19 '15 at 23:00