Share via


MauiHandlersCollectionExtensions.TryAddHandler Method

Definition

Overloads

TryAddHandler(IMauiHandlersCollection, Type, Type)

Registers a handler with the underlying service container via AddTransient.

TryAddHandler<TType,TTypeRender>(IMauiHandlersCollection)

Registers a handler with the underlying service container via AddTransient.

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

Registers a handler with the underlying service container via AddTransient.

TryAddHandler(IMauiHandlersCollection, Type, Type)

Source:
MauiHandlersCollectionExtensions.cs
Source:
MauiHandlersCollectionExtensions.cs

Registers a handler with the underlying service container via AddTransient.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Maui::Hosting::IMauiHandlersCollection ^ TryAddHandler(Microsoft::Maui::Hosting::IMauiHandlersCollection ^ handlersCollection, Type ^ viewType, Type ^ handlerType);
public static Microsoft.Maui.Hosting.IMauiHandlersCollection TryAddHandler (this Microsoft.Maui.Hosting.IMauiHandlersCollection handlersCollection, Type viewType, Type handlerType);
static member TryAddHandler : Microsoft.Maui.Hosting.IMauiHandlersCollection * Type * Type -> Microsoft.Maui.Hosting.IMauiHandlersCollection
<Extension()>
Public Function TryAddHandler (handlersCollection As IMauiHandlersCollection, viewType As Type, handlerType As Type) As IMauiHandlersCollection

Parameters

handlersCollection
IMauiHandlersCollection

The handler collection

viewType
Type

The type of element to register

handlerType
Type

The handler type that represents the element

Returns

The handler collection

Applies to

TryAddHandler<TType,TTypeRender>(IMauiHandlersCollection)

Source:
MauiHandlersCollectionExtensions.cs
Source:
MauiHandlersCollectionExtensions.cs

Registers a handler with the underlying service container via AddTransient.

public:
generic <typename TType, typename TTypeRender>
 where TType : Microsoft::Maui::IView where TTypeRender : Microsoft::Maui::IViewHandler[System::Runtime::CompilerServices::Extension]
 static Microsoft::Maui::Hosting::IMauiHandlersCollection ^ TryAddHandler(Microsoft::Maui::Hosting::IMauiHandlersCollection ^ handlersCollection);
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;
static member TryAddHandler : Microsoft.Maui.Hosting.IMauiHandlersCollection -> Microsoft.Maui.Hosting.IMauiHandlersCollection (requires 'ype :> Microsoft.Maui.IView and 'ypeRender :> Microsoft.Maui.IViewHandler)
<Extension()>
Public Function TryAddHandler(Of TType As IView, TTypeRender As IView) (handlersCollection As IMauiHandlersCollection) As IMauiHandlersCollection

Type Parameters

TType

The type of element to register

TTypeRender

The handler type that represents the element

Parameters

handlersCollection
IMauiHandlersCollection

The handler collection

Returns

The handler collection

Applies to

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

Source:
MauiHandlersCollectionExtensions.cs
Source:
MauiHandlersCollectionExtensions.cs

Registers a handler with the underlying service container via AddTransient.

public:
generic <typename TType>
 where TType : Microsoft::Maui::IElement[System::Runtime::CompilerServices::Extension]
 static Microsoft::Maui::Hosting::IMauiHandlersCollection ^ TryAddHandler(Microsoft::Maui::Hosting::IMauiHandlersCollection ^ handlersCollection, Func<IServiceProvider ^, Microsoft::Maui::IElementHandler ^> ^ handlerImplementationFactory);
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;
static member TryAddHandler : Microsoft.Maui.Hosting.IMauiHandlersCollection * Func<IServiceProvider, Microsoft.Maui.IElementHandler> -> Microsoft.Maui.Hosting.IMauiHandlersCollection (requires 'ype :> Microsoft.Maui.IElement)
<Extension()>
Public Function TryAddHandler(Of TType As IElement) (handlersCollection As IMauiHandlersCollection, handlerImplementationFactory As Func(Of IServiceProvider, IElementHandler)) As IMauiHandlersCollection

Type Parameters

TType

The type of element to register

Parameters

handlersCollection
IMauiHandlersCollection

The handler collection

handlerImplementationFactory
Func<IServiceProvider,IElementHandler>

A factory method to create the handler

Returns

The handler collection

Applies to