Prism Workaround for RequestNavigate view verbosity?

I am using prism navigation based on view using the RequestNavigate method.

The problem I am facing is that I have to register all ViewModels with the container:

container.RegisterType<object, InboxView>("InboxView");

This is very verbose and requires a list of all the types of views that I want to register.
Is there a workaround for this?

I think RequestNavigate should have been generic:

IRegion.RequestNavigate<TView>();

And the following should be done:

  • Allow Submission
  • Give the mind a name in the area that should be typeof(TView).Name
  • Run the actual navigation request :)
  • Please vote for my suggestion on the Prism list of issues.
+3
source share
1

, , RegionManager. :

  • . A B, , , , 3- ?
  • . , .

.

, , , , , RegionManager. , , , , . IRegionManager IRegion.

public interface IMyNavigationService
{
     //Your own implementation could use (typeof(T)).Name (or 
     //AttributedModelServices.GetContractName(typeof(T)) if using MEF)
     //as the Key, if thatis appropriate for your solution 
     //(1 instance T per region and references to T from all Modules)
     void RequestNavigation<T>();
}

, MEF IoC ... , . RegisterType<object, InboxView>. MEF:

[Export]
public class InboxView { .. }

([Export("InboxView")]), AttributedModelServices.GetContractName(typeof(InboxView)). , , IMyNavigationService, .

, ( MEF... , Unity... )

public static class RegionExtensions
{
    public static void RequestNavigate<T>(this IRegion region)
    {
        region.RequestNavigate(AttributedModelServices.GetContractName(typeof(T)));
    }
}

MEF, MefContrib, ... Unity MEF .

, .

0

All Articles