0
votes

just started stydying Prism. Can someone explain what I am doing wrong here...

I have basically 2 regions. 1 region - left menu. 2 region - content. They are all in the shell.

Left menu view and the content views are all in the separate projects.
Now, I would like on some button clicks in the left menu switch the views in the content region.

What i have done: - created NavigationCommand + added it to the composite command (not relevant right now)

  public LeftMenuViewModel(IRegionManager regionManager)
        {
            _regionManager = regionManager;
            NavigateCommand  = new DelegateCommand<object>(Navigate);
            AppCommands.NavigateCommand.RegisterCommand(NavigateCommand);
        }

+

public void Navigate (object navigatePath)
        {
            if (navigatePath !=null)
            {
                _regionManager.RequestNavigate(RegionNames.ContentRegion, navigatePath.ToString());
            }
        }
  • in my leftmenu view i have next piece of code:

    dc:ButtonDropDown Header=" Enter New Client" Style="{DynamicResource AppMenuCommandButton}" Command="{x:Static Infrastracture:AppCommands.NavigateCommand}" CommandParameter="ClientNewView"

Now, the command works and hits Navigate method in LeftMenuViewModel, it just refuses to load the content views (from different project) into Content Region, instead it just gives 'System.Object' in the content region.

I assume the problem is in this line of code:

 _regionManager.RequestNavigate(RegionNames.ContentRegion, navigatePath.ToString());

we can't just load the views from different project?

Do I have to register the views with the container in the Content Views project? Like this: _container.RegisterType<object, ClientNewView>(typeof (ClientNewView).FullName);?

thanks for any help !

1
I just used EventAggregator for communication the message among the views. Thanks.HotFrost

1 Answers

0
votes

I'm not sure what container you use, but with MEF you have to either:

a. Register library with container in bootstrapper

OR

b. Create separate project as a PRISM Module and add it to catalog. Then PRISM will import this library automatically

Now, this will solve your problem I think.

But if it doesn't - you need to trap navigation error. RequestNavigate swallows exceptions and to see them you need to subscribe for it like shown here: http://blogs.southworks.net/gmaliandi/2011/08/how-to-prevent-region-navigation-from-hiding-exceptions-in-prism/