Forum Xamarin.Forms

Dependency injection using PRISM Xamarin Forms doesn't work

blackpantificblackpantific Member ✭✭
edited December 2019 in Xamarin.Forms

I have a problem with dependency injection in my project. I use PRISM framework in my project and I chose Ioc container when create it. Link ->
In my app.xaml file I associate the class and interface

protected override void RegisterTypes(IContainerRegistry containerRegistry)
containerRegistry.RegisterForNavigation<WelcomeView, WelcomeViewModel>();
containerRegistry.RegisterForNavigation<RegistrationView, RegistrationViewModel>();
containerRegistry.RegisterForNavigation<LoginView, LoginViewModel>();

        containerRegistry.RegisterSingleton<IValidationService, ValidationService>();

But my page after initializing() doesn't appear at the screen. This is ViewModel constructor

public RegistrationViewModel(INavigationService navigationService, IUserDataService userDataService,
IValidationService validationService) :
_userDataService = userDataService;
_validationService = validationService;

Something wrong here. I read the instructions on the site with the PRISM documentation and did as it says, what am I doing wrong?

Best Answer

  • blackpantificblackpantific Member ✭✭
    Accepted Answer

    I found a solution to the problem, I did not register all the interface-object pairs


Sign In or Register to comment.