MauiHandlersCollectionExtensions.TryAddHandler 方法

定义

重载

TryAddHandler(IMauiHandlersCollection, Type, Type)

通过 AddTransient 向基础服务容器注册处理程序。

TryAddHandler<TType,TTypeRender>(IMauiHandlersCollection)

通过 AddTransient 向基础服务容器注册处理程序。

TryAddHandler<TType>(IMauiHandlersCollection, Func<IServiceProvider,IElementHandler>)

通过 AddTransient 向基础服务容器注册处理程序。

TryAddHandler(IMauiHandlersCollection, Type, Type)

Source:
MauiHandlersCollectionExtensions.cs
Source:
MauiHandlersCollectionExtensions.cs

通过 AddTransient 向基础服务容器注册处理程序。

public static Microsoft.Maui.Hosting.IMauiHandlersCollection TryAddHandler(this Microsoft.Maui.Hosting.IMauiHandlersCollection handlersCollection, Type viewType, Type handlerType);

参数

handlersCollection
IMauiHandlersCollection

处理程序集合

viewType
Type

要注册的元素的类型

handlerType
Type

表示元素的处理程序类型

返回

处理程序集合

适用于

.NET MAUI 9 和 .NET MAUI 8
产品 版本
.NET MAUI 8, 9

TryAddHandler<TType,TTypeRender>(IMauiHandlersCollection)

Source:
MauiHandlersCollectionExtensions.cs
Source:
MauiHandlersCollectionExtensions.cs

通过 AddTransient 向基础服务容器注册处理程序。

public static Microsoft.Maui.Hosting.IMauiHandlersCollection TryAddHandler<TType,TTypeRender>(this Microsoft.Maui.Hosting.IMauiHandlersCollection handlersCollection) where TType : Microsoft.Maui.IView where TTypeRender : Microsoft.Maui.IViewHandler;

类型参数

TType

要注册的元素的类型

TTypeRender

表示元素的处理程序类型

参数

handlersCollection
IMauiHandlersCollection

处理程序集合

返回

处理程序集合

适用于

.NET MAUI 9 和 .NET MAUI 8
产品 版本
.NET MAUI 8, 9

TryAddHandler<TType>(IMauiHandlersCollection, Func<IServiceProvider,IElementHandler>)

Source:
MauiHandlersCollectionExtensions.cs
Source:
MauiHandlersCollectionExtensions.cs

通过 AddTransient 向基础服务容器注册处理程序。

public static Microsoft.Maui.Hosting.IMauiHandlersCollection TryAddHandler<TType>(this Microsoft.Maui.Hosting.IMauiHandlersCollection handlersCollection, Func<IServiceProvider,Microsoft.Maui.IElementHandler> handlerImplementationFactory) where TType : Microsoft.Maui.IElement;

类型参数

TType

要注册的元素的类型

参数

handlersCollection
IMauiHandlersCollection

处理程序集合

handlerImplementationFactory
Func<IServiceProvider,IElementHandler>

用于创建处理程序的工厂方法

返回

处理程序集合

适用于

.NET MAUI 9 和 .NET MAUI 8
产品 版本
.NET MAUI 8, 9