CanExecuteRoutedEventArgs Class
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
'Declaration Public NotInheritable Class CanExecuteRoutedEventArgs Inherits RoutedEventArgs 'Usage Dim instance As CanExecuteRoutedEventArgs
public final class CanExecuteRoutedEventArgs extends RoutedEventArgs
public final class CanExecuteRoutedEventArgs extends RoutedEventArgs
You cannot use this managed class in XAML.
Typically, a command source, such a MenuItem, will call the CanExecute method on a RoutedCommand to determine if the command can or cannot execute on the current command target. If CanExecute is set to false, the command source will disable itself. For example, if a MenuItem is acting as the command source for a command and the command cannot execute on the current command target, then the MenuItem will gray itself out.
The CanExecuteChanged event notifies a command source when the ability of a command to execute may have changed.
The follow example creates a CanExecuteRoutedEventHandler that returns true only if the command target is a control. First, Source is cast to a Control. If Source is a Control, CanExecute is set to true; otherwise, it is set to false.
// CanExecuteRoutedEventHandler that only returns true if // the source is a control. public void CanExecuteCustomCommand(object sender, CanExecuteRoutedEventArgs e) { Control target = e.Source as Control; if(target != null) { e.CanExecute = true; } else { e.CanExecute = false; } }
System.EventArgs
System.Windows.RoutedEventArgs
System.Windows.Input.CanExecuteRoutedEventArgs
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.