Friday, April 15, 2011

MVVM - ViewModel which is also a region?

I have a "DataRegion" that is an ItemsControl. I add ViewModels to it and through DataTemplating the views are rendered.

My question is that this ItemsControl now needs logic to do with setting up Commands in menus for the Items (they can't do it themselves as it the logic is dependendant on the number of items, i.e. there must be one item visible all the time)

I want it to be a ViewModel, but can't work out how to instaniate it and associate it to the items control?

I can't bind it to the items control as the region will throw an error. I have added it as a property to the shell and it currently accesses the region views to get to the child viewmodels that it needs to control.

Any better ideas?

From stackoverflow

0 comments:

Post a Comment