Apr 3, 2011 at 8:56 PM
Edited Apr 3, 2011 at 9:01 PM
I have an interesting situation and kind of stuck for now.
I have a ToolbarView that I would like to reuse within my application. Therefore I would have three ViewModels that would use the same view. I thought I could create a base class or interface for the View's ctor in this case.
Now I am actually already using an ItemsControl that is a region within my Shell:
Each tab on this region would contain a ContactView that takes a ContactViewModel injected. So far so good.
Now I need to have a Region defined within the ContactView to register a ToolbarView in there and inject my ToolbarCallViewModel in there. A ToolbarView outside my ContactView for example would get a plain
ToolbarViewModel injected. etc
I have created a contentcontrol within the Contact View in order to do the plan above:
Now within my adding a ContactView to the ItemsControl (mainRegion) mechanism I do the following:
// Add the View in a new Tab
var contactViewModel = _container.Resolve<ContactViewModel>();
var view = new ContactView(contactViewModel);
var toolbarCallViewModel = _container.Resolve<ToolbarCallViewModel>();
var viewCallToolbar = new ToolbarView(toolbarCallViewModel);
_regionManager.Regions[Constants.ToolbarCallRegion].Add(viewCallToolbar, contact.ContactID + "callToolbar");
Now the last line works only the first time I am adding a view. Since its only a ContentControl, this approach seems wrong to me. How would it even know that this Region is meant to be unique within that ContactView?
I hope you guys know what I mean,
Thanks for help,