Share via


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
Public propertySupported by Silverlight for Windows Phone AllowDrop Gets or sets a value that determines whether this UIElement can be a drop target for purposes of Silverlight drag-and-drop operations.
Public propertySupported by Silverlight for Windows Phone CacheMode Gets or sets a value that indicates that rendered content should be cached when possible.
Public propertySupported by Silverlight for Windows Phone Clip Gets or sets the Geometry used to define the outline of the contents of a UIElement.
Public propertySupported by Silverlight for Windows Phone DesiredSize Gets the size that this UIElement computed during the measure pass of the layout process.
Public propertySupported by Silverlight for Windows Phone Dispatcher Gets the Dispatcher this object is associated with. (Inherited from DependencyObject.)
Public property Effect Gets or sets the pixel shader effect to use for rendering this UIElement.
Public propertySupported by Silverlight for Windows Phone IsHitTestVisible Gets or sets whether the contained area of this UIElement can return true values for hit testing.
Public propertySupported by Silverlight for Windows Phone Opacity Gets or sets the degree of the object's opacity.
Public propertySupported by Silverlight for Windows Phone OpacityMask Gets or sets the brush used to alter the opacity of regions of this object.
Public propertySupported by Silverlight for Windows Phone Projection Gets or sets the perspective projection (3-D effect) to apply when rendering this UIElement.
Public propertySupported by Silverlight for Windows Phone RenderSize Gets the final render size of a UIElement.
Public propertySupported by Silverlight for Windows Phone RenderTransform Gets or sets transform information that affects the rendering position of a UIElement.
Public propertySupported by Silverlight for Windows Phone RenderTransformOrigin Gets or sets the origin point of any possible render transform declared by RenderTransform, relative to the bounds of the UIElement.
Public propertySupported by Silverlight for Windows Phone 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.
Public propertySupported by Silverlight for Windows Phone 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
Public methodSupported by Silverlight for Windows Phone 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.
Public methodSupported by Silverlight for Windows Phone 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.
Public methodSupported by Silverlight for Windows Phone CaptureMouse Sets mouse capture to a UIElement.
Public methodSupported by Silverlight for Windows Phone CheckAccess Determines whether the calling thread has access to this object. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone ClearValue Clears the local value of a dependency property. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone 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.)
Public methodSupported by Silverlight for Windows Phone 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.)
Public methodSupported by Silverlight for Windows Phone GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetType Gets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetValue Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone InvalidateArrange Invalidates the arrange state (layout) for a UIElement. After the invalidation, the UIElement will have its layout updated, which will occur asynchronously.
Public methodSupported by Silverlight for Windows Phone InvalidateMeasure Invalidates the measurement state (layout) for a UIElement.
Public methodSupported by Silverlight for Windows Phone 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.
Protected methodSupported by Silverlight for Windows Phone MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone OnCreateAutomationPeer When implemented in a derived class, returns class-specific AutomationPeer implementations for the Silverlight automation infrastructure.
Public methodSupported by Silverlight for Windows Phone ReadLocalValue Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone ReleaseMouseCapture Removes mouse capture from a UIElement. After this call, typically no object holds mouse capture.
Public methodSupported by Silverlight for Windows Phone RemoveHandler Removes the specified routed event handler from this UIElement.
Public methodSupported by Silverlight for Windows Phone SetValue Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone ToString Returns a string that represents the current object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone TransformToVisual Returns a transform object that can be used to transform coordinates from the UIElement to the specified object.
Public methodSupported by Silverlight for Windows Phone UpdateLayout Ensures that all positions of child objects of a UIElement are properly updated for layout.

Top

Events

  Name Description
Public eventSupported by Silverlight for Windows Phone DoubleTap Occurs when a DoubleTap gesture is committed while over this UIElement.
Public event DragEnter Occurs when the input system reports an underlying drag event with this element as the target.
Public event DragLeave Occurs when the input system reports an underlying drag event with this element as the origin.
Public event DragOver Occurs when the input system reports an underlying drag event with this element as the potential drop target.
Public event Drop Occurs when the input system reports an underlying drop event with this element as the drop target.
Public eventSupported by Silverlight for Windows Phone GotFocus Occurs when a UIElement receives focus.
Public eventSupported by Silverlight for Windows Phone Hold Occurs when a Hold gesture is committed while over this UIElement.
Public eventSupported by Silverlight for Windows Phone KeyDown Occurs when a keyboard key is pressed while the UIElement has focus.
Public eventSupported by Silverlight for Windows Phone KeyUp Occurs when a keyboard key is released while the UIElement has focus.
Public eventSupported by Silverlight for Windows Phone LostFocus Occurs when a UIElement loses focus.
Public eventSupported by Silverlight for Windows Phone LostMouseCapture Occurs when the UIElement loses mouse capture.
Public eventSupported by Silverlight for Windows Phone ManipulationCompleted Occurs when a manipulation and inertia on the UIElement is complete.
Public eventSupported by Silverlight for Windows Phone ManipulationDelta Occurs when the input device changes position during a manipulation.
Public eventSupported by Silverlight for Windows Phone ManipulationStarted Occurs when an input device begins a manipulation on the UIElement.
Public event MediaCommand Occurs when a button is pressed on a remote control.
Public eventSupported by Silverlight for Windows Phone MouseEnter Occurs when the mouse (or a stylus) enters the bounding area of a UIElement.
Public eventSupported by Silverlight for Windows Phone MouseLeave Occurs when the mouse (or the stylus) leaves the bounding area of a UIElement.
Public eventSupported by Silverlight for Windows Phone 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.
Public eventSupported by Silverlight for Windows Phone 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).
Public eventSupported by Silverlight for Windows Phone MouseMove Occurs when the coordinate position of the mouse (or stylus) changes while over a UIElement (or while a UIElement holds mouse capture).
Public event MouseRightButtonDown Occurs when the right mouse button is pressed while the mouse pointer is over a UIElement.
Public event 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.
Public eventSupported by Silverlight for Windows Phone MouseWheel Occurs when the user rotates the mouse wheel while the mouse pointer is over a UIElement, or the UIElement has focus.
Public eventSupported by Silverlight for Windows Phone Tap Occurs when a Tap gesture is committed while over this UIElement.
Public eventSupported by Silverlight for Windows Phone TextInput Occurs when a UI element gets text in a device-independent manner.
Public eventSupported by Silverlight for Windows Phone TextInputStart Occurs when a UI element initially gets text in a device-independent manner.
Public eventSupported by Silverlight for Windows Phone TextInputUpdate Occurs when text continues to be composed via an input method editor (IME).

Top

Fields

  Name Description
Public fieldStatic memberSupported by Silverlight for Windows Phone AllowDropProperty Identifies the AllowDrop dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone CacheModeProperty Identifies the CacheMode dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone ClipProperty Identifies the Clip dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone DoubleTapEvent Identifies the DoubleTap routed event.
Public fieldStatic member EffectProperty Identifies the Effect dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone HoldEvent Identifies the Hold routed event.
Public fieldStatic memberSupported by Silverlight for Windows Phone IsHitTestVisibleProperty Identifies the IsHitTestVisible dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone KeyDownEvent Identifies the KeyDown routed event.
Public fieldStatic memberSupported by Silverlight for Windows Phone KeyUpEvent Identifies the KeyUp routed event.
Public fieldStatic memberSupported by Silverlight for Windows Phone ManipulationCompletedEvent Identifies the ManipulationCompleted routed event.
Public fieldStatic memberSupported by Silverlight for Windows Phone ManipulationDeltaEvent Identifies the ManipulationDelta routed event.
Public fieldStatic memberSupported by Silverlight for Windows Phone ManipulationStartedEvent Identifies the ManipulationStarted routed event.
Public fieldStatic memberSupported by Silverlight for Windows Phone MouseLeftButtonDownEvent Identifies the MouseLeftButtonDown routed event.
Public fieldStatic memberSupported by Silverlight for Windows Phone MouseLeftButtonUpEvent Identifies the MouseLeftButtonUp routed event.
Public fieldStatic member MouseRightButtonDownEvent Identifies the MouseRightButtonDown routed event.
Public fieldStatic member MouseRightButtonUpEvent Identifies the MouseRightButtonUp routed event.
Public fieldStatic member MouseWheelEvent Identifies the MouseWheel routed event.
Public fieldStatic memberSupported by Silverlight for Windows Phone OpacityMaskProperty Identifies the IsHitTestVisible dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone OpacityProperty Identifies the IsHitTestVisible dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone ProjectionProperty Identifies the Projection dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone RenderTransformOriginProperty Identifies the RenderTransformOrigin dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone RenderTransformProperty Identifies the RenderTransform dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone TapEvent Identifies the Tap routed event.
Public fieldStatic memberSupported by Silverlight for Windows Phone TextInputEvent Identifies the TextInput routed event.
Public fieldStatic memberSupported by Silverlight for Windows Phone TextInputStartEvent Identifies the TextInputStart routed event.
Public fieldStatic memberSupported by Silverlight for Windows Phone TextInputUpdateEvent Identifies the TextInputUpdate routed event.
Public fieldStatic memberSupported by Silverlight for Windows Phone UseLayoutRoundingProperty Identifies the UseLayoutRounding dependency property.
Public fieldStatic memberSupported by Silverlight for Windows Phone 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:

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.