简体   繁体   中英

Uno Platform Using Dependency Injection

I am trying to inject dependencies into a constructor of a ViewModel in a project using the Mvvm framework. I am using the Uno Platform. I tried Mvvm frameworks Prism and Mvvmcross but they remain incomplete and I couldn't get them to build. I am now trying Mvvmhelpers which builds fine but I don't think that caters for a IOC container.Could someone recommned a way forward?

Uno Platform can use any .NET Standard library, so you could potentially just install Autofac or Unity and plug it into your custom MVVM framework.

MvvmLight binding is provided via Uno.MvvmLight , which is also available as a NuGet package in preview . Although it hasn't been updated for a while, I will put up a Issue on GitHub to get it up to date again with the upstream.

For my personal favorite MvvmCross - there is a work in progress PR on GitHub , which will bring Uno support directly into MvvmCross. But before that happens, you can follow the instructions from Nick Randolph on his blog to get the preview version up and running.

The platform is still quite new so it takes time for things to settle and third party libraries to adopt it, but after the release of WinUI 3.0 it should stabilize and the support should grow faster.

Update

I totally forgot to mention ReactiveUI which has first-party support for Uno Platform already.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM