MauiHandlersCollectionExtensions.TryAddHandler 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
TryAddHandler(IMauiHandlersCollection, Type, Type) |
透過 AddTransient 向基礎服務容器註冊處理程式。 |
TryAddHandler<TType,TTypeRender>(IMauiHandlersCollection) |
透過 AddTransient 向基礎服務容器註冊處理程式。 |
TryAddHandler<TType>(IMauiHandlersCollection, Func<IServiceProvider,IElementHandler>) |
透過 AddTransient 向基礎服務容器註冊處理程式。 |
TryAddHandler(IMauiHandlersCollection, Type, Type)
透過 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
參數
- handlersCollection
- IMauiHandlersCollection
處理程式集合
- viewType
- Type
要註冊的項目類型
- handlerType
- Type
表示專案的處理程序類型
傳回
處理程式集合
適用於
TryAddHandler<TType,TTypeRender>(IMauiHandlersCollection)
透過 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
類型參數
- TType
要註冊的項目類型
- TTypeRender
表示專案的處理程序類型
參數
- handlersCollection
- IMauiHandlersCollection
處理程式集合
傳回
處理程式集合
適用於
TryAddHandler<TType>(IMauiHandlersCollection, Func<IServiceProvider,IElementHandler>)
透過 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
類型參數
- TType
要註冊的項目類型
參數
- handlersCollection
- IMauiHandlersCollection
處理程式集合
- handlerImplementationFactory
- Func<IServiceProvider,IElementHandler>
用來建立處理程式的 Factory 方法
傳回
處理程式集合