Jan 25, 2012 at 11:06 AM


I'm going on splitting my WPF app in modules... since I've created an interface IMenuItem that represent a viewmodel that should be loaded in the Menu I've done so

    public class myViewModel : mySimpleScreen<myResult>//, IHaveHelp



is this ok? if I don't export the myViewModelType I got an exception when from menu I try to load the view in the WorkSpaceViewModel

  public void Handle(MenuMessage message)
            var typeSpecific = message.MenuItemType;
            IScreen screen = _viewModelFactory.Get(typeSpecific);

            if (null != screen)

If it's ok I continue this way...Thanks

Jan 25, 2012 at 1:35 PM

It depends on how large or complex your application is. From your code, it looks like you are exporting myViewModel as both a screen and a menu item. I generally like to create separate models for these two things. That doesn't mean that what you are doing is wrong. It may be just fine for your scenario. Just keep that in the back of your mind so that if you encounter issues or friction with this design later, you have some idea how you might change things.

Jan 25, 2012 at 1:48 PM

Hello Eisenberg,

as I told you before I splitted my project into modules, I've got a Menu that by now is a mess of MenuItem menu1 = new Menu("topLevel1)... etc.. now that I'm refactoring I wish that each module tell's what the ViewModel that will be appear in the menu are

Consider this scenario Module1 has 2 viewModel VM1 and VM2, Module2 VM1

In my MenuViewModel I have

     var menuItems = _compositionContainer.GetExportedValues<IMenuItem>()

that returns me a flat list of the ViewModels that expose the IMenuItem interface... but here I've lost the hierarchy of the Menu.... I wish that each Module (aka Assembly) knows internally of which viewmodel compose the menu... is it possible?

One idea I've is to create a Presenter.cs in each module that expose a ITopLevelMenuItem and has this structure

 public interface ITopLevelMenuItem
        string Description { get; }

        IEnumerable<IMenuItem> GetChildren();


I don't know btw how to implement the GetChildren ... how to get from each assembly "I'm composed of VM1, VM2"

Can you please help?