ContentElement.RemoveHandler(RoutedEvent, Delegate) ContentElement.RemoveHandler(RoutedEvent, Delegate) ContentElement.RemoveHandler(RoutedEvent, Delegate) Method

定義

從這個項目中移除指定的路由事件處理常式。Removes the specified routed event handler from this element.

public:
 virtual void RemoveHandler(System::Windows::RoutedEvent ^ routedEvent, Delegate ^ handler);
public void RemoveHandler (System.Windows.RoutedEvent routedEvent, Delegate handler);
abstract member RemoveHandler : System.Windows.RoutedEvent * Delegate -> unit
override this.RemoveHandler : System.Windows.RoutedEvent * Delegate -> unit

參數

routedEvent
RoutedEvent RoutedEvent RoutedEvent

要附加處理常式之路由事件的識別項。The identifier of the.routed event for which the handler is attached.

handler
Delegate Delegate Delegate

要從這個項目上的事件處理常式集合中移除的特定處理常式實作。The specific handler implementation to remove from the event handler collection on this element.

實作

備註

最常見的使用APIAPI案例是當您執行與自訂路由事件相關聯的通用語言執行平台 (CLR)common language runtime (CLR) 「包裝函式」事件時, 特別是當您在CLRCLR層級執行處理常式的「移除」邏輯時。The most common scenario for using this APIAPI is when you implement the 通用語言執行平台 (CLR)common language runtime (CLR) "wrapper" event that is associated with a custom routed event, specifically when you implement the "remove" logic for handlers at the CLRCLR level. 遵循此備註一節的範例將說明這種情況。The example that follows this remarks section illustrates this scenario.

如果沒有使用符合方法呼叫之輸入參數的條件來註冊任何處理程式, 則呼叫這個方法不會有任何作用。Calling this method has no effect if there were no handlers registered with criteria that match the input parameters for the method call.

如果附加了一個以上符合準則的處理常式, 則只會移除事件處理常式存放區中的第一個處理常式。If more than one handler is attached that matched the criteria, only the first handler in the event handler store is removed. 這個行為與CLRCLR -=運算子的行為一致。This behavior is consistent with CLRCLR behavior of the -= operator.

routedEvent null都不是。handlerNeither routedEvent nor handler may be null. 嘗試提供任何一個值時null , 將會引發例外狀況。Attempting to provide either value as null will raise an exception.

這個方法會忽略handledEventsToo參數資訊, 如果處理常式最初是AddHandler(RoutedEvent, Delegate, Boolean)以簽章來加入, 而此簽章可讓您處理已經處理的事件, 就會提供此資訊。This method ignores the handledEventsToo parameter information, which is provided if the handler was first added with the AddHandler(RoutedEvent, Delegate, Boolean) signature that enables handling of already-handled events. 已移除任一類型的處理常式。Either type of handler is removed.

適用於

另請參閱