Intersoft ClientUI Documentation
ExecutedRoutedEventHandler Delegate
See Also  Send Feedback
Intersoft.Client.Framework.Input Namespace : ExecutedRoutedEventHandler Delegate






sender
The object where the event handler is attached.
e
The event data.
Represents the method that will handle the CommandBinding.Executed and CommandBinding.PreviewExecuted routed events, as well as related attached events.

Syntax

Visual Basic (Declaration) 
Public Delegate Sub ExecutedRoutedEventHandler( _
   ByVal sender As Object, _
   ByVal e As ExecutedRoutedEventArgs _
) 
Visual Basic (Usage)Copy Code
Dim instance As New ExecutedRoutedEventHandler(AddressOf HandlerMethod)
C# 
public delegate void ExecutedRoutedEventHandler( 
   object sender,
   ExecutedRoutedEventArgs e
)
Delphi 
public delegate ExecutedRoutedEventHandler( 
    sender: TObject;
    e: ExecutedRoutedEventArgs
);
JScript 
public delegate ExecutedRoutedEventHandler( 
   sender : Object,
   e : ExecutedRoutedEventArgs
)
Managed Extensions for C++ 
public: __gc __delegate void ExecutedRoutedEventHandler( 
   Object* sender,
   ExecutedRoutedEventArgs* e
)
C++/CLI 
public delegate void ExecutedRoutedEventHandler( 
   Object^ sender,
   ExecutedRoutedEventArgs^ e
)

Parameters

sender
The object where the event handler is attached.
e
The event data.

Remarks

This delegate contains the implementation logic for a RoutedCommand. Separating the implementation logic from the command allows the command to be invoked from different sources and types, and enables the centralization of command logic.

This delegate is also used for CommandManager .Executed and CommandManager .PreviewExecuted, which are routed events on the CommandManager class that implements much of the commanding infrastructure. But most practical handlers will handle the Executed events from a particular CommandBinding, rather than work at the CommandManager level.

Within ExecutedRoutedEventArgs, the following properties are generally of interest when you write an event handler for a routed event that results from an executed command:

  • Source reports the target where the command was executed. Once the command is executed, you can also think of the Source more generally in routed event terms, as the object that raised a routed event.

  • Command reports the command that executed. This property is useful if you use command bindings and if you write handlers that potentially handle multiple commands.

  • Parameter reports any command-specific parameters that were passed by the executing command. Not all commands use or expect command-specific parameters.

  • Handled reports whether the routed event that resulted from the executed command was already handled by a different element along the route. For routed event handlers, it is a recommended practice to have handlers that do meaningful work when handling the event to set Handled to true. This prevents typical handlers for the event from handling the event again further along the route. For more information on handling routed events, see How to: Mark a Routed Event as Handled.

The following code example shows the event handler for the Executed routed event for the CommandBinding which is associated to a routed command.

C# Copy Code
private void CutExecuted(object sender, ExecutedRoutedEventArgs e)
{
     string command = ((RoutedCommand)e.Command).Name;
     string target = ((FrameworkElement)e.OriginalSource).Name;

     MessageBox.Show("The " + command +  " command has been invoked on target object " + target);
}

For a more complete version of the above example, see How-to: Implement a RoutedCommand. For more information on commanding, see Commanding Overview.

 

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2012 All Rights Reserved.