Event handlers in Windows Presentation Foundation are very
similar to handlers in traditional Windows Forms. An object as sender and an
event argument object are two parameters which form the typical signature for
event handlers.
Each event handler has some information about the specific
event type that it represents so you can use it in your code to accomplish
several tasks and get helpful information about the event and the element that
has received the event. Properties for each event argument type may vary from one
another but some properties are common between event arguments.
Here I give a list of eight event argument types with a
description about the purpose and usage of each one.
·
RoutedEventArgs: This event argument type is a base type for some
other argument types. RoutedEventArgs, Itself, is the argument type that will
be passed to some events like Click and Close.
·
KeyEventArgs: An event argument type for key events such as KeyUp
or KeyDown.
·
MouseEventArgs: An event argument type to work with the mouse and
its events. Generally it's useful when you want to work with mouse states.
·
MouseButtonEventArgs: An extension of MouseEventArgs which adds
some functionality to work with mouse button events.
·
TextChangedEventArgs: An event argument which provides properties
for the TextChanged event. It's inherited from RoutedEventArgs.
·
SelectionChangedEventArgs: An event argument which provides
properties for SelectionChanged event. It's inherited from RoutedEventArgs.
·
ScrollChangedEventArgs: An event argument which provides
properties for working with scrollbar events. It's inherited from
RoutedEventArgs.
·
DependencyPropertyChangedEventArgs: This event argument is passed
to events when a dependency property is changed.