Xamarin Prism IOC

Posted on


sorry for this type of question, I am wondering if are there any good code practice to use in order to isolate IOCs on my App.cs RegisterTypes since it’s getting bigger. Like isolating the registration of navigation and abstractions. E.g.

protected override void RegisterTypes()

Where NavigationPage to NavigationPage3 and NavigationPage_1_1 to NavigationPage_1_3 will be both isolated.



If I’m reading this correctly you want to have different way to group pages together for registration. Besides making a new method for each group there isn’t a good way by hand to do this. At the end all your pages are still registered in the same container. You could create child containers for each group but then need to make extension methods for navigation that knows about child containers. Yuck and over-kill.

If your main issue is that the registration method is getting too big then just look at switching it around. We use MEF to load a catalog and have all our views have a RegisterView attribute than use the MEF catalog to build the registrations for the views in Prism. We use MEF for other things in our application and I think it would be over kill to use MEF just for registration. Another way instead of MEF is to just use reflection and to wire it up yourself. I was going to write the code how to do that but did a quick Google search and low and behold Stack Overflow already had an answer


They just looking for Pages but if you wanted you could make an attribute and look for that if you needed but Page object is probably what you need.

Leave a Reply

Your email address will not be published. Required fields are marked *