CommandManager.RemovePreviewCanExecuteHandler(UIElement, CanExecuteRoutedEventHandler) Method

Definition

从指定的元素分离指定的 CanExecuteRoutedEventHandlerDetaches the specified CanExecuteRoutedEventHandler from the specified element.

public:
 static void RemovePreviewCanExecuteHandler(System::Windows::UIElement ^ element, System::Windows::Input::CanExecuteRoutedEventHandler ^ handler);
public static void RemovePreviewCanExecuteHandler (System.Windows.UIElement element, System.Windows.Input.CanExecuteRoutedEventHandler handler);
static member RemovePreviewCanExecuteHandler : System.Windows.UIElement * System.Windows.Input.CanExecuteRoutedEventHandler -> unit
Public Shared Sub RemovePreviewCanExecuteHandler (element As UIElement, handler As CanExecuteRoutedEventHandler)

Parameters

element
UIElement

要从中移除 handler 的元素。The element to remove handler from.

handler
CanExecuteRoutedEventHandler

可以执行的处理程序。The can execute handler.

Exceptions

elementhandlernullelement or handler is null.

Examples

下面的示例将 CanExecuteRoutedEventHandler 和之前附加到 ButtonExecutedRoutedEventHandler 分离。The following example detaches a CanExecuteRoutedEventHandler and an ExecutedRoutedEventHandler which had previously been attached to a Button.

CommandManager.RemoveExecutedHandler(helpButton, HelpCmdExecuted);
CommandManager.RemoveCanExecuteHandler(helpButton, HelpCmdCanExecute);
CommandManager.RemoveExecutedHandler(helpButton, AddressOf HelpCmdExecuted)
CommandManager.RemoveCanExecuteHandler(helpButton, AddressOf HelpCmdCanExecute)

Applies to

See also