What I do is create a view registry in my Shell with the following interface (I'm simplifying here):
public interface IViewRegistry
{
void RegisterView(string title, string key, Func<UIElement> viewCreationMethod);
void OpenView(string key);
}
This is way oversimplifying, but hopefully this gives you a picture. Each module registers its views with the shell using this interface on initialization. In my shell, I create a ViewStore that stores these things.
public static class ViewStore
{
public Dictionary<string, ViewEntry> Views { get; set; }
static ViewStore()
{
Views = new Dictionary<string, ViewEntry>();
}
public void RegisterView(string name, string key, Func<UIElement> createMethod)
{
Views.Add(key, new ViewEntry() { Name = name, CreateMethod = createMethod });
}
}
Then from my IViewRegistry implementation:
public class ViewRegistryService : IViewRegistry
{
public void RegisterView(string title, string key, Func<UIElement> createMethod)
{
ViewStore.RegisterView(title, key, createMethod);
}
public void OpenView(string key)
{
//Check here with your region manager to see if
//the view is already open, if not, inject it
var view = _regionManager.Regions["MyRegion"].GetView(key);
if(view != null)
{
view = ViewStore.Views[key]();
_regionManager.Regions["MyRegion"].Add(view, key);
}
_regionManager.Regions["MyRegion"].Activate(view);
}
private IRegionManager _regionManager;
public ViewRegistryService(IRegionManager rm)
{
_regionManager = rm;
}
}
Now I have two things:
- A ViewStore I can use to create a menu in my shell.
- A way for modules to open views owned by other modules without coupling beyond simple ModuleDependencies (in reality, even the ModuleDependency is not necessary, but probably correct.
Obviously this way oversimplifies things. I have things that indicate whether or not a view should be a menu item. My app has several menus, etc, but this is the basics and should get you going.
Also, you should give Stackoverflow a little bit of a chance to get you an answer... you only gave us 3 hours before you gave up :)
Hope this helps.