C#C
C#3y ago
1 reply
AceOfAces

❔ Cannot plugin HanumanInstitute.MvvmDialogs with MS.Extensions.DependencyInjection

I'm having trouble plugging in the HanumanInstitute.MvvmDialogs with my project (that uses Microsoft.Extensions.DependencyInjection. Every time I try to create a ViewModel with the dialog service, I get the error on the screenshot. I have no idea how to initialize the ModelViewFactory. How can I do that?

I am using Avalonia, but it should be reproducible with WPF.

Here's the code for registering the dialog service:
            var services = new ServiceCollection();
            services.AddSingleton<IDialogService>(x => new DialogService(
            new DialogManager(
                viewLocator: new StrongViewLocator(),
                dialogFactory: new DialogFactory().AddMessageBox().AddFluent(FluentMessageBoxType.ContentDialog)),
            viewModelFactory: z => x.GetService(z)));
            AppServices = services.BuildServiceProvider();
image.png
Was this page helpful?