UIElement is a base class for most of the objects that have visual appearance and can process basic input in a user interface.
Inheritance
- Object
- DependencyObject
- UIElement
Syntax
Attributes
- MarshalingBehaviorAttribute(Agile)
- StaticAttribute(Windows.UI.Xaml.IUIElementStatics, NTDDI_WIN8)
- ThreadingAttribute(Both)
- VersionAttribute(NTDDI_WIN8)
- WebHostHiddenAttribute()
Members
The UIElement class has these types of members:
Events
The UIElement class has these events.
| Event | Description |
|---|---|
| DoubleTapped | Occurs when an otherwise unhandled DoubleTap interaction occurs over the hit test area of this element. |
| 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. |
| Holding | Occurs when an otherwise unhandled Hold interaction occurs over the hit test area of this element. |
| 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. |
| ManipulationCompleted | Occurs when a manipulation on the UIElement is complete. |
| ManipulationDelta | Occurs when the input device changes position during a manipulation. |
| ManipulationInertiaStarting | Occurs when the input device loses contact with the UIElement object during a manipulation and inertia begins. |
| ManipulationStarted | Occurs when an input device begins a manipulation on the UIElement. |
| ManipulationStarting | Occurs when the manipulation processor is first created. |
| PointerCanceled | Occurs when a pointer that made contact abnormally loses contact. |
| PointerCaptureLost | Occurs when pointer capture previously held by this element moves to another element or elsewhere. |
| PointerEntered | Occurs when a pointer enters the hit test area of this element. |
| PointerExited | Occurs when a pointer leaves the hit test area of this element. |
| PointerMoved | Occurs when a pointer moves while the pointer remains within the hit test area of this element. |
| PointerPressed | Occurs when the pointer device initiates a Press action within this element. |
| PointerReleased | Occurs when the pointer device that previously initiated a Press action is released, while within this element. |
| PointerWheelChanged | Occurs when the delta value of a pointer wheel changes. |
| RightTapped | Occurs when a right-tap input stimulus happens while the pointer is over the element. |
| Tapped | Occurs when an otherwise unhandled Tap interaction occurs over the hit test area of this element. |
Methods
The UIElement class has these methods. It also inherits methods from the Object class.
| Method | 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 even if the event is handled elsewhere. |
| 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. |
| CapturePointer | Sets pointer capture to a UIElement. Once captured, only the element that has capture will fire pointer-related events. |
| ClearValue | Clears the local value of a dependency property. (Inherited from DependencyObject) |
| FindSubElementsForTouchTargeting | Enables a UIElement subclass to expose child elements that assist with resolving touch targeting. |
| GetAnimationBaseValue | Returns any base value established for a dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject) |
| 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. |
| OnCreateAutomationPeer | When implemented in a derived class, returns class-specific AutomationPeer implementations for the Microsoft UI Automation infrastructure. |
| OnDisconnectVisualChildren | Override this method to implement how layout and logic should behave when items are removed from a class-specific content or children property. |
| ReadLocalValue | Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject) |
| ReleasePointerCapture | Releases pointer captures for capture of one specific pointer by this UIElement. |
| ReleasePointerCaptures | Releases all pointer captures held by this element. |
| RemoveHandler | Removes the specified routed event handler from this UIElement. Typically the handler in question was added by AddHandler. |
| SetValue | Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject) |
| 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. |
Properties
The UIElement class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read/write | Gets or sets a value that determines whether this UIElement can be a drop target for purposes of drag-and-drop operations. | |
| Read-only | Identifies the AllowDrop dependency property. | |
| Read/write | Gets or sets a value that indicates that rendered content should be cached as a composited bitmap when possible. | |
| Read-only | Identifies the CacheMode dependency property. | |
| Read/write | Gets or sets the RectangleGeometry used to define the outline of the contents of a UIElement. | |
| Read-only | Identifies the Clip dependency property. | |
| Read-only | Gets the size that this UIElement computed during the measure pass of the layout process. | |
| Read-only | Gets the CoreDispatcher that this object is associated with. (Inherited from DependencyObject) | |
| Read-only | Gets the identifier for the DoubleTapped routed event. | |
| Read-only | Gets the identifier for the DragEnter routed event. | |
| Read-only | Gets the identifier for the DragLeave routed event. | |
| Read-only | Gets the identifier for the DragOver routed event. | |
| Read-only | Gets the identifier for the Drop routed event. | |
| Read-only | Gets the identifier for the Holding routed event. | |
| Read/write | Gets or sets a value that determines whether the DoubleTapped event can originate from that element. | |
| Read-only | Identifies the IsDoubleTapEnabled dependency property. | |
| Read/write | Gets or sets whether the contained area of this UIElement can return true values for hit testing. | |
| Read-only | Identifies the IsHitTestVisible dependency property. | |
| Read/write | Gets or sets a value that determines whether the Holding event can originate from that element. | |
| Read-only | Identifies the IsHoldingEnabled dependency property. | |
| Read/write | Gets or sets a value that determines whether the RightTapped event can originate from that element. | |
| Read-only | Identifies the IsRightTapEnabled dependency property. | |
| Read/write | Gets or sets a value that determines whether the Tapped event can originate from that element. | |
| Read-only | Identifies the IsTapEnabled dependency property. | |
| Read-only | Gets the identifier for the KeyDown routed event. | |
| Read-only | Gets the identifier for the KeyUp routed event. | |
| Read-only | Gets the identifier for the ManipulationCompleted routed event. | |
| Read-only | Gets the identifier for the ManipulationDelta routed event. | |
| Read-only | Gets the identifier for the ManipulationInertiaStarting routed event. | |
| Read/write | Gets or sets the ManipulationModes value used for UIElement behavior and interaction with gestures. | |
| Read-only | Identifies the ManipulationMode dependency property. | |
| Read-only | Gets the identifier for the ManipulationStarted routed event. | |
| Read-only | Gets the identifier for the ManipulationStarting routed event. | |
| Read/write | Gets or sets the degree of the object's opacity. | |
| Read-only | Identifies the IsHitTestVisible dependency property. | |
| Read-only | Gets the identifier for the PointerCanceled routed event. | |
| Read-only | Gets the identifier for the PointerCaptureLost routed event. | |
| Read-only | Gets the set of all captured pointers, represented as Pointer values. | |
| Read-only | Identifies the PointerCaptures dependency property. | |
| Read-only | Gets the identifier for the PointerEntered routed event. | |
| Read-only | Gets the identifier for the PointerExited routed event. | |
| Read-only | Gets the identifier for the PointerMoved routed event. | |
| Read-only | Gets the identifier for the PointerPressed routed event. | |
| Read-only | Gets the identifier for the PointerReleased routed event. | |
| Read-only | Gets the identifier for the PointerWheelChanged routed event. | |
| Read/write | Gets or sets the perspective projection (3-D effect) to apply when rendering this element. | |
| Read-only | Identifies the Projection dependency property. | |
| Read-only | Gets the final render size of a UIElement. | |
| Read/write | Gets or sets transform information that affects the rendering position of a UIElement. | |
| Read/write | Gets or sets the origin point of any possible render transform declared by RenderTransform, relative to the bounds of the UIElement. | |
| Read-only | Identifies the RenderTransformOrigin dependency property. | |
| Read-only | Identifies the RenderTransform dependency property. | |
| Read-only | Gets the identifier for the RightTapped routed event. | |
| Read-only | Gets the identifier for the Tapped routed event. | |
| Read/write | Gets or sets the collection of Transition style elements that apply to a UIElement. | |
| Read-only | Identifies the Transitions dependency property. | |
| Read/write | 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. | |
| Read-only | Identifies the UseLayoutRounding dependency property. | |
| Read/write | Gets or sets the visibility of a UIElement. A UIElement that is not visible is not rendered and does not communicate its desired size to layout. | |
| Read-only | Identifies the Visibility dependency property. |
Remarks
UIElement provides a starting point for layout characteristics. FrameworkElement adds more layout capabilities.
Much of the input behavior for visible elements in a UI is defined in the UIElement class. This includes the events for keyboard, pointers, touch, manipulations, 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. For more info, see Events and routed events overview.
UIElement has properties that can influence the element's preferences for processing input. For example, you can enable the element to be a drop target with AllowDrop, or disable tap response with IsTapEnabled.
Although UIElement defines the events for focus reporting (GotFocus, LostFocus), UIElement does not define an API for programmatically setting the focus. This capability is defined by the Control class.
UIElement does not expose a public constructor. Typically, you don't derive classes from either UIElement or FrameworkElement directly. More typically used base classes for derived custom classes are these classes:
- Specific controls that are not sealed (for example, TextBox)
- Control base classes (Control, ContentControl, UserControl)
- Navigation elements (Page, Frame)
- Panel classes (the base class Panel, or specific non-sealed implementations such as Grid)
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 1/31/2013