0

Is it possible to use dependency injection for .net maui converters?

I've found Prism can do that: How to resolve a dependency in IValueConverter in Xamarin.Forms using Prism/DryIoC

but how about regular Microsoft.Extensions.DependencyInjection? is something similar doable? I want to reference to IOptions<ApiSettings> apiSettings inside it

I got No constructor for type 'MyConverter' has 0 parameters error if I try to use converter with 1-param constructor in xaml.

YMC
  • 4,925
  • 7
  • 53
  • 83
  • 1
    Meanwhile, until a better way found, I decided to use this approach https://github.com/davidortinau/WeatherTwentyOne/blob/main/src/WeatherTwentyOne/Services/ServiceExtensions.cs - getting it from application, it's not quite complaint with the best practices, but I've not found better way to do it – YMC Feb 17 '23 at 19:34

0 Answers0