views:

351

answers:

2

I'm developing an app and need some guidance on the best approach...

For instance I have a main view using its viewmodel to retrieve many recipes. I want to be able to bind each recipe to a recipe user control within an items control and then each control will be responsible for instantiating it's viewmodel.

Should I use a dependency property within the each recipe user control or what other alternatives do people suggest for creating multiple recipe user controls?

I'm keen to adopt MVVM Light given it's Blendability features.

A: 

It's a weird approach the thing you want but... If you have a list of recipes in your mainviewmodel, you can bind it to the itemscontrol. In the ItemsControl every item will be a recipe UC with a recipe of the list.

It's that what you want?

Jesus Rodriguez
A: 

I agree with Jesus here. The best approach is to create a list of recipes, and a DataTemplate. The DataContext of each item in the list control will automatically be set to the corresponding Recipe. If you implement the Recipe class as a ViewModelBase, you get INotifyPropertyChanged and you can raise the propertychanged event when your properties change. This is the standard way of doing this.

Cheers, Laurent

LBugnion