小智 9
我在Jame Montemagno 的 Youtube上找到了这个。我想这就是您正在寻找的。视频在这里。
public static class ServiceHelper {
public static T GetService<T>() => Current.GetService<T>();
public static IServiceProvider Current =>
#if WINDOWS10_0_17763_0_OR_GREATER
MauiWinUIApplication.Current.Services;
#elif ANDROID
MauiApplication.Current.Services;
#elif IOS || MACCATALYST
MauiUIApplicationDelegate.Current.Services;
#else
null;
#endif }
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4492 次 |
最近记录: |