UIElement Class
Microsoft Silverlight will reach end of support after October 2021. Learn more.
UIElement is a base class for most of the objects that have visual appearance and can process basic input in Silverlight.
Inheritance Hierarchy
System.Object
System.Windows.DependencyObject
System.Windows.UIElement
System.Windows.FrameworkElement
Namespace: System.Windows
Assembly: System.Windows (in System.Windows.dll)
Syntax
'Declaration
Public MustInherit Class UIElement _
Inherits DependencyObject
public abstract class UIElement : DependencyObject
The UIElement type exposes the following members.
Properties
Name | Description | |
---|---|---|
AllowDrop | Gets or sets a value that determines whether this UIElement can be a drop target for purposes of Silverlight drag-and-drop operations. | |
CacheMode | Gets or sets a value that indicates that rendered content should be cached when possible. | |
Clip | Gets or sets the Geometry used to define the outline of the contents of a UIElement. | |
DesiredSize | Gets the size that this UIElement computed during the measure pass of the layout process. | |
Dispatcher | Gets the Dispatcher this object is associated with. (Inherited from DependencyObject.) | |
Effect | Gets or sets the pixel shader effect to use for rendering this UIElement. | |
IsHitTestVisible | Gets or sets whether the contained area of this UIElement can return true values for hit testing. | |
Opacity | Gets or sets the degree of the object's opacity. | |
OpacityMask | Gets or sets the brush used to alter the opacity of regions of this object. | |
Projection | Gets or sets the perspective projection (3-D effect) to apply when rendering this UIElement. | |
RenderSize | Gets the final render size of a UIElement. | |
RenderTransform | Gets or sets transform information that affects the rendering position of a UIElement. | |
RenderTransformOrigin | Gets or sets the origin point of any possible render transform declared by RenderTransform, relative to the bounds of the UIElement. | |
UseLayoutRounding | Gets or sets a value that determines whether rendering for the object and its visual subtree should use rounding behavior that aligns rendering to whole pixels. | |
Visibility | Gets or sets the visibility of a UIElement. A UIElement that is not visible does not render and does not communicate its desired size to layout. |
Top
Methods
Name | Description | |
---|---|---|
AddHandler | Adds a routed event handler for a specified routed event, adding the handler to the handler collection on the current element. Specify handledEventsToo as true to have the provided handler be invoked for routed event that had already been marked as handled by another element along the event route. | |
Arrange | Positions child objects and determines a size for a UIElement. Parent objects that implement custom layout for their child elements should call this method from their layout override implementations to form a recursive layout update. | |
CaptureMouse | Sets mouse capture to a UIElement. | |
CheckAccess | Determines whether the calling thread has access to this object. (Inherited from DependencyObject.) | |
ClearValue | Clears the local value of a dependency property. (Inherited from DependencyObject.) | |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
GetAnimationBaseValue | Returns any base value established for a Silverlight dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GetValue | Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.) | |
InvalidateArrange | Invalidates the arrange state (layout) for a UIElement. After the invalidation, the UIElement will have its layout updated, which will occur asynchronously. | |
InvalidateMeasure | Invalidates the measurement state (layout) for a UIElement. | |
Measure | Updates the DesiredSize of a UIElement. Typically, objects that implement custom layout for their layout children call this method from their own MeasureOverride implementations to form a recursive layout update. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnCreateAutomationPeer | When implemented in a derived class, returns class-specific AutomationPeer implementations for the Silverlight automation infrastructure. | |
ReadLocalValue | Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.) | |
ReleaseMouseCapture | Removes mouse capture from a UIElement. After this call, typically no object holds mouse capture. | |
RemoveHandler | Removes the specified routed event handler from this UIElement. | |
SetValue | Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
TransformToVisual | Returns a transform object that can be used to transform coordinates from the UIElement to the specified object. | |
UpdateLayout | Ensures that all positions of child objects of a UIElement are properly updated for layout. |
Top
Events
Name | Description | |
---|---|---|
DoubleTap | Occurs when a DoubleTap gesture is committed while over this UIElement. | |
DragEnter | Occurs when the input system reports an underlying drag event with this element as the target. | |
DragLeave | Occurs when the input system reports an underlying drag event with this element as the origin. | |
DragOver | Occurs when the input system reports an underlying drag event with this element as the potential drop target. | |
Drop | Occurs when the input system reports an underlying drop event with this element as the drop target. | |
GotFocus | Occurs when a UIElement receives focus. | |
Hold | Occurs when a Hold gesture is committed while over this UIElement. | |
KeyDown | Occurs when a keyboard key is pressed while the UIElement has focus. | |
KeyUp | Occurs when a keyboard key is released while the UIElement has focus. | |
LostFocus | Occurs when a UIElement loses focus. | |
LostMouseCapture | Occurs when the UIElement loses mouse capture. | |
ManipulationCompleted | Occurs when a manipulation and inertia on the UIElement is complete. | |
ManipulationDelta | Occurs when the input device changes position during a manipulation. | |
ManipulationStarted | Occurs when an input device begins a manipulation on the UIElement. | |
MediaCommand | Occurs when a button is pressed on a remote control. | |
MouseEnter | Occurs when the mouse (or a stylus) enters the bounding area of a UIElement. | |
MouseLeave | Occurs when the mouse (or the stylus) leaves the bounding area of a UIElement. | |
MouseLeftButtonDown | Occurs when the left mouse button is pressed (or when the tip of the stylus touches the tablet) while the mouse pointer is over a UIElement. | |
MouseLeftButtonUp | Occurs when the left mouse button is released (or the tip of the stylus is removed from the tablet) while the mouse (or the stylus) is over a UIElement (or while a UIElement holds mouse capture). | |
MouseMove | Occurs when the coordinate position of the mouse (or stylus) changes while over a UIElement (or while a UIElement holds mouse capture). | |
MouseRightButtonDown | Occurs when the right mouse button is pressed while the mouse pointer is over a UIElement. | |
MouseRightButtonUp | Occurs when the right mouse button is released while the mouse pointer is over a UIElement. However, this event will only be raised if a caller marks the preceding MouseRightButtonDown event as handled; see Remarks. | |
MouseWheel | Occurs when the user rotates the mouse wheel while the mouse pointer is over a UIElement, or the UIElement has focus. | |
Tap | Occurs when a Tap gesture is committed while over this UIElement. | |
TextInput | Occurs when a UI element gets text in a device-independent manner. | |
TextInputStart | Occurs when a UI element initially gets text in a device-independent manner. | |
TextInputUpdate | Occurs when text continues to be composed via an input method editor (IME). |
Top
Fields
Name | Description | |
---|---|---|
AllowDropProperty | Identifies the AllowDrop dependency property. | |
CacheModeProperty | Identifies the CacheMode dependency property. | |
ClipProperty | Identifies the Clip dependency property. | |
DoubleTapEvent | Identifies the DoubleTap routed event. | |
EffectProperty | Identifies the Effect dependency property. | |
HoldEvent | Identifies the Hold routed event. | |
IsHitTestVisibleProperty | Identifies the IsHitTestVisible dependency property. | |
KeyDownEvent | Identifies the KeyDown routed event. | |
KeyUpEvent | Identifies the KeyUp routed event. | |
ManipulationCompletedEvent | Identifies the ManipulationCompleted routed event. | |
ManipulationDeltaEvent | Identifies the ManipulationDelta routed event. | |
ManipulationStartedEvent | Identifies the ManipulationStarted routed event. | |
MouseLeftButtonDownEvent | Identifies the MouseLeftButtonDown routed event. | |
MouseLeftButtonUpEvent | Identifies the MouseLeftButtonUp routed event. | |
MouseRightButtonDownEvent | Identifies the MouseRightButtonDown routed event. | |
MouseRightButtonUpEvent | Identifies the MouseRightButtonUp routed event. | |
MouseWheelEvent | Identifies the MouseWheel routed event. | |
OpacityMaskProperty | Identifies the IsHitTestVisible dependency property. | |
OpacityProperty | Identifies the IsHitTestVisible dependency property. | |
ProjectionProperty | Identifies the Projection dependency property. | |
RenderTransformOriginProperty | Identifies the RenderTransformOrigin dependency property. | |
RenderTransformProperty | Identifies the RenderTransform dependency property. | |
TapEvent | Identifies the Tap routed event. | |
TextInputEvent | Identifies the TextInput routed event. | |
TextInputStartEvent | Identifies the TextInputStart routed event. | |
TextInputUpdateEvent | Identifies the TextInputUpdate routed event. | |
UseLayoutRoundingProperty | Identifies the UseLayoutRounding dependency property. | |
VisibilityProperty | Identifies the Visibility dependency property. |
Top
Remarks
UIElement provides a starting point for Silverlight layout characteristics; FrameworkElement adds more layout capabilities.
Much of the input behavior for visible elements in a Silverlight UI is defined in the UIElement class. This includes the events for keyboard, mouse and stylus input, and focus events. Some of these events are routed events. A routed event enables a built-in event handling notification system, so that a parent object can handle input events from child objects in the object tree if the event remains unhandled. This input event behavior is useful for input area grouping, and for control compositing.
Although UIElement defines the events for focus reporting (GotFocus, LostFocus), UIElement does not define an API for programmatically setting the focus. However, this capability is defined by the Control class and is thus present for many of the Silverlight elements in a UI.
UIElement does not expose a public constructor. It is not typical to derive from either UIElement or FrameworkElement directly. More typically used base classes for derived custom classes in Silverlight are these classes:
Specific controls that are not sealed (for example, TextBox)
Control base classes (Control, ContentControl, UserControl)
Panel classes (the base class Panel, or specific non-sealed panel implementations, for example Grid)
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.