tags:

views:

46

answers:

1

Hi,

I am new to Prism WPF world, have one simple question.

I have registered my view and viewmodel in the module initialise method like below

        var navigatorView = new NavigationMenu.View.NavigationBarView();
        navigatorView.DataContext = m_Container.Resolve<NavigationMenuViewModel>();
        var regionManager = m_Container.Resolve<IRegionManager>();            
        regionManager.Regions[RegionNames.NavigationMenuRegion].Add(navigatorView);

Now if I want to modify my ViewModel then the only way i am able to do that is through ViewModel class only, is there any other way where I can update the viewmodel object registered with the unity container. Also i would like to know how can i get the object instance registered with the unity container.

Thanks and Regards, Harry

A: 

Any of your VMs or Modules should have that Initialize-Method, which gets those container, regionmanager and eventaggregator objects passed via parameters. In the first place (like your bootstrapper) you put them in those containers. You use a method like RegisterType for this. Then you can get those objects with the Resolve method, just like you did in your code example.

This means, wherever you want to manipulate a specific VM you use Resolve to get that VM. I probably didn't understand your question correctly. So please explain a little further, or be a bit more specific where you got problems.

Torsten