Section 12.2. Event Argument Reference


12.2. Event Argument Reference

The signature for event handlers is primarily the same for all events; only the event argument changes for different types of events. The syntax for all event handlers is:

     C#:         public void HandlerName(Object sender, EventArgs e)     Visual Basic:         Sub HandlerName(ByVal sender As Object, ByVal e As EventArgs) 

Each event argument type holds values specific to the event as well as general data such as the source element and the original source element. This section details the event argument types.

RoutedEventArgs

RoutedEventArgs is the base class for many other routed event argument types and is also the argument type passed to the event handler for events such as Click and Closed.

Properties


Handled

This Boolean designates whether the event has been handled. If it is set to true, then no other event handlers will be invoked.


OriginalSource

OriginalSource is stored as an Object and is generally cast to FrameworkElement in order to determine its true type. OriginalSource is the original element that raised the event.


RoutedEvent

This RoutedEvent type indicates the associated routed event. This value can never be null.


Source

Source is stored as an Object, and is generally cast to FrameworkElement in order to determine its true type. Because of routing strategies, Source may not be the original source of the event.

DependencyPropertyChangedEventArgs

DependencyPropertyChangedEventArgs is passed to handlers that are raised when a dependency property changes. It is not associated with routed events. DependencyProp-ertyChangedEventArgs has properties that help to determine both the old value and new attribute values. This class also allows you to programmatically determine the state of a selector, such as CheckBox or RadioButton, as well as handle changes in other properties.

Properties


NewValue

NewValue is an Object that can be cast to the appropriate type. NewValue holds the new value of the property.


OldValue

OldValue is an Object that can be cast to the appropriate type. OldValue holds the previous value of the property.


Property

This field returns the actual property that has been changed, allowing you to programmatically manipulate it.


PropertyName

This String represents the name of the property that has been changed.

KeyEventArgs

KeyEventArgs describes the arguments passed to a handler for a key-based event, such as KeyUp or KeyDown.

Properties


Device

This property gets or sets the InputDevice that raised the event.


Handled

This Boolean designates whether the event has been handled. If it is set to true, then no other event handlers will be invoked.


InputSource

This property is the PresentationSource that raised the event. At this time, there is only one implementation of a presentation source: the Windows standard HwndSource.


IsDown

This Boolean indicates whether the key referenced by the event is down.


IsRepeat

This Boolean indicates whether the key referenced by the event is a repeated key.


IsToggled

This Boolean indicates whether the key referenced by the event is toggled.


IsUp

This Boolean indicates whether the key referenced by the event is up.


Key

This Key (enumeration) indicates the key referenced by the event. See Microsoft's documentation for Key enumeration values.


KeyboardDevice

KeyboardDevice contains the logical KeyboardDevice.


KeyState

This KeyState (enumeration containing Down, None, Toggled) indicates the state of the key associated with the event.


OriginalSource

OriginalSource is stored as an Object and is generally cast to FrameworkElement in order to determine its true type. OriginalSource is the original element that raised the event.


RoutedEvent

This property indicates the associated routed event. This value can never be null.


Source

Source is stored as an Object and is generally cast to FrameworkElement in order to determine its true type. Because of routing strategies, Source may not be the original source of the event.


SystemKey

This property indicates the Key associated with this event if the event is going to be processed by the system.


TimeStamp

This property is an Integer representing the time the event occurred.

ScrollChangedEventArgs

ScrollChangedEventArgs is derived from RoutedEventArgs and extends the class with properties specific to scrollbars.

Properties


HorizontalChange

A Double value indicating the amount of horizontal change in the scrolled content


HorizontalOffset

A Double value indicating the updated horizontal position of the content


VerticalChange

A Double value indicating the amount of vertical change in the scrolled content


VerticalOffset

A Double value indicating the updated vertical position of the content

TextChangedEventArgs

TextChangedEventArgs is derived from RoutedEventArgs and adds properties specific to the TextChanged event

Properties


UndoAction

UndoAction is an enumeration indicating how the change in text will affect the undo stack.


Clear

The action will clear the undo stack.


Create

The action will create a new undo stack.


Merge

This change will merge into the previous undo stack.


None

This change will not affect the undo stack.


Redo

This change is the result of a call to Redo( ).


Undo

This change is the result of a call to Undo( ).

MouseEventArgs

MouseEventArgs provide access to the mouse and its various states.

Properties


Device

This property gets or sets the InputDevice that raised the event.


Handled

This Boolean designates whether the event has been handled. If it is set to true, then no other event handlers will be invoked.


LeftButton

This MouseButtonState (an enumeration containing Pressed and Released) indicates the state of the left button of the mouse.


MiddleButton

This MouseButtonState (an enumeration containing Pressed and Released) indicates the state of the middle button of the mouse.


MouseDevice

This property gets the MouseDevice associated with the event.


OriginalSource

OriginalSource is stored as an Object and is generally cast to FrameworkElement in order to determine its true type. OriginalSource is the original element that raised the event.


RightButton

This MouseButtonState (an enumeration containing Pressed and Released) indicates the state of the right button of the mouse.


RoutedEvent

This property indicates the associated routed event. This value can never be null.


Source

Source is stored as an Object and is generally cast to type FrameworkElement in order to determine its true type. Because of routing strategies, Source may not be the original source of the event.


StylusPointer

This Object represents the stylus mouse associated with the event.


TimeStamp

This Integer represents the time the event occurred.


XButton1

This MouseButtonState (an enumeration containing Pressed and Released) indicates the state of the first extended button of the mouse.


XButton2

This MouseButtonState (an enumeration containing Pressed and Released) indicates the state of the second extended button of the mouse.

MouseButtonEventArgs

MouseButtonEventArgs extends MouseEventArgs and adds several properties dealing specifically with the mouse buttons. It is generally used by non-routed mouse button events such as MouseLeftButtonDown and MouseLeftButtonUp.

Properties


ButtonState

This property is read-only and indicates the MouseButtonState (Pressed or Released) of the mouse button associated with the event.


ChangedButton

This property is read-only and indicates which MouseButton (an enumeration containing Left, Middle, Right, XButton1, or XButton2) has changed.


ClickCount

This Integer indicates the click count of the button associated with the event.

SelectionChangedEventArgs

SelectionChangedEventArgs is derived from RoutedEventArgs and adds properties specific to the SelectionChanged event.

Properties


SelectedItems

SelectedItems is an IList (a non-generic collection of objects that can be accessed by index) of all items selected as a result of this event.


UnselectedItems

UnselectedItems is an IList (a non-generic collection of objects that can be accessed by index) of all items unselected as a result of this event.




XAML in a Nutshell
XAML in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596526733
EAN: 2147483647
Year: 2007
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net