views:

76

answers:

1

I want to create a project that contains 2 views and 2 viewmodels. One of the views will display persons that i get from a feed and the other will display the weather which I also receive from a feed.

Now in my viewmodellocator constructor I have static ViewModelLocator() { Container = new UnityContainer();

        if (ViewModelBase.IsInDesignModeStatic)
        {
            Container.RegisterType<IPersonService, Design.DesignDataService>();
        }
        else
        {
            Container.RegisterType<IPersonService, PersonService>();
        }

        Container.RegisterType<MainViewModel>(new ContainerControlledLifetimeManager());
    }

    // Access

    public MainViewModel Main
    {
        get
        {
            return Container.Resolve<MainViewModel>();
        }
    }     

then I set to use it in the view

But how can I add my weather view? In main my constructor looks like this public MainViewModel(ICommentService commentsService)

do I need an additional parameter in the constructor?

would appreciate if anyone could help

A: 

Personally, I don't register my Views with my container - only my ViewModels. I typically only have a single instance of any view, so I just create a new instance inside of it's parent ViewModel.

Matt Casto
Yes but I have many instances of the same view (only with different url)
So you can send a notificationMessage with the url if needed.
Rick Ratayczak