jahu00 / RikaiKyun2Research

Preproduction research for a new version of RikaiKyun
0 stars 0 forks source link

Figure out DI in MAUI #7

Closed jahu00 closed 1 year ago

jahu00 commented 1 year ago

I need to access resources (such as IFontCollection for fonts) and MauiApp is some kind of host class, but I have no idea how to access services from inside my of control.

jahu00 commented 1 year ago

DI in MAUI is not quite what I expected, but I can access services using

Handler.MauiContext.Services.GetService()

If I used MVVM, I could probably use DI through constructor inside model class.

However I didn't find the services I was expecting to (namely IFontCollection). To give SKCanvasView a fighting chance I need to figure out hot to read resources from assembly.