EN
Este conteúdo não está disponível em seu idioma, mas aqui está a versão em inglês.

UIElement class

Applies to Windows and Windows Phone

UIElement is a base class for most of the Windows Runtime UI objects that have visual appearance and can process basic input as part of your app's user interface.

Inheritance

Object
  DependencyObject
    UIElement

Syntax


public class UIElement : DependencyObject

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

Members

The UIElement class has these types of members:

Events

The UIElement class has these events.

EventDescription
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.

MethodDescription
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.
CancelDirectManipulations Cancels ongoing direct manipulation processing (system-defined panning/zooming) on any ScrollViewer parent that contains the current UIElement.
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.

PropertyAccess typeDescription

AllowDrop

Read/writeGets or sets a value that determines whether this UIElement can be a drop target for purposes of drag-and-drop operations.

AllowDropProperty

Read-onlyIdentifies the AllowDrop dependency property.

CacheMode

Read/writeGets or sets a value that indicates that rendered content should be cached as a composited bitmap when possible.

CacheModeProperty

Read-onlyIdentifies the CacheMode dependency property.

Clip

Read/writeGets or sets the RectangleGeometry used to define the outline of the contents of a UIElement.

ClipProperty

Read-onlyIdentifies the Clip dependency property.

CompositeMode

Read/writeGets or sets a property that declares alternate composition and blending modes for the element in its parent layout and window. This is relevant for elements that are involved in a mixed XAML / Microsoft DirectX UI.

CompositeModeProperty

Read-onlyIdentifies the CompositeMode dependency property.

DesiredSize

Read-onlyGets the size that this UIElement computed during the measure pass of the layout process.

Dispatcher

Read-onlyGets the CoreDispatcher that this object is associated with. (Inherited from DependencyObject)

DoubleTappedEvent

Read-onlyGets the identifier for the DoubleTapped routed event.

DragEnterEvent

Read-onlyGets the identifier for the DragEnter routed event.

DragLeaveEvent

Read-onlyGets the identifier for the DragLeave routed event.

DragOverEvent

Read-onlyGets the identifier for the DragOver routed event.

DropEvent

Read-onlyGets the identifier for the Drop routed event.

HoldingEvent

Read-onlyGets the identifier for the Holding routed event.

IsDoubleTapEnabled

Read/writeGets or sets a value that determines whether the DoubleTapped event can originate from that element.

IsDoubleTapEnabledProperty

Read-onlyIdentifies the IsDoubleTapEnabled dependency property.

IsHitTestVisible

Read/writeGets or sets whether the contained area of this UIElement can return true values for hit testing.

IsHitTestVisibleProperty

Read-onlyIdentifies the IsHitTestVisible dependency property.

IsHoldingEnabled

Read/writeGets or sets a value that determines whether the Holding event can originate from that element.

IsHoldingEnabledProperty

Read-onlyIdentifies the IsHoldingEnabled dependency property.

IsRightTapEnabled

Read/writeGets or sets a value that determines whether the RightTapped event can originate from that element.

IsRightTapEnabledProperty

Read-onlyIdentifies the IsRightTapEnabled dependency property.

IsTapEnabled

Read/writeGets or sets a value that determines whether the Tapped event can originate from that element.

IsTapEnabledProperty

Read-onlyIdentifies the IsTapEnabled dependency property.

KeyDownEvent

Read-onlyGets the identifier for the KeyDown routed event.

KeyUpEvent

Read-onlyGets the identifier for the KeyUp routed event.

ManipulationCompletedEvent

Read-onlyGets the identifier for the ManipulationCompleted routed event.

ManipulationDeltaEvent

Read-onlyGets the identifier for the ManipulationDelta routed event.

ManipulationInertiaStartingEvent

Read-onlyGets the identifier for the ManipulationInertiaStarting routed event.

ManipulationMode

Read/writeGets or sets the ManipulationModes value used for UIElement behavior and interaction with gestures. Setting this value enables handling the manipulation events from this element in app code.

ManipulationModeProperty

Read-onlyIdentifies the ManipulationMode dependency property.

ManipulationStartedEvent

Read-onlyGets the identifier for the ManipulationStarted routed event.

ManipulationStartingEvent

Read-onlyGets the identifier for the ManipulationStarting routed event.

Opacity

Read/writeGets or sets the degree of the object's opacity.

OpacityProperty

Read-onlyIdentifies the IsHitTestVisible dependency property.

PointerCanceledEvent

Read-onlyGets the identifier for the PointerCanceled routed event.

PointerCaptureLostEvent

Read-onlyGets the identifier for the PointerCaptureLost routed event.

PointerCaptures

Read-onlyGets the set of all captured pointers, represented as Pointer values.

PointerCapturesProperty

Read-onlyIdentifies the PointerCaptures dependency property.

PointerEnteredEvent

Read-onlyGets the identifier for the PointerEntered routed event.

PointerExitedEvent

Read-onlyGets the identifier for the PointerExited routed event.

PointerMovedEvent

Read-onlyGets the identifier for the PointerMoved routed event.

PointerPressedEvent

Read-onlyGets the identifier for the PointerPressed routed event.

PointerReleasedEvent

Read-onlyGets the identifier for the PointerReleased routed event.

PointerWheelChangedEvent

Read-onlyGets the identifier for the PointerWheelChanged routed event.

Projection

Read/writeGets or sets the perspective projection (3-D effect) to apply when rendering this element.

ProjectionProperty

Read-onlyIdentifies the Projection dependency property.

RenderSize

Read-onlyGets the final render size of a UIElement.

RenderTransform

Read/writeGets or sets transform information that affects the rendering position of a UIElement.

RenderTransformOrigin

Read/writeGets or sets the origin point of any possible render transform declared by RenderTransform, relative to the bounds of the UIElement.

RenderTransformOriginProperty

Read-onlyIdentifies the RenderTransformOrigin dependency property.

RenderTransformProperty

Read-onlyIdentifies the RenderTransform dependency property.

RightTappedEvent

Read-onlyGets the identifier for the RightTapped routed event.

TappedEvent

Read-onlyGets the identifier for the Tapped routed event.

Transitions

Read/writeGets or sets the collection of Transition style elements that apply to a UIElement.

TransitionsProperty

Read-onlyIdentifies the Transitions dependency property.

UseLayoutRounding

Read/writeGets 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.

UseLayoutRoundingProperty

Read-onlyIdentifies the UseLayoutRounding dependency property.

Visibility

Read/writeGets 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.

VisibilityProperty

Read-onlyIdentifies the Visibility dependency property.

 

Remarks

UIElement is a base element: it's a class that many other Windows Runtime classes inherit from in order to support the XAML UI element model. Properties, methods and events that UIElement defines are inherited by hundreds of other Windows Runtime classes.

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:

The UIElement class is used as the type parameter of many properties and methods in the Windows Runtime API. For example, the Child property of Border takes a single UIElement, which represents the element that the Border is drawn around. You can provide any UIElement-derived element for such a property, including custom controls that you define.

The UIElementCollection class provides a strongly typed collection of UIElement items. UIElementCollection is used as a type for properties of objects that contain several child elements, for example for the Children property of any Panel class.

UIElement API and features

UIElement extends DependencyObject, which is another base element, and adds support for various Windows Runtime feature areas.

Input, and events for responding to user interaction

Much of the input behavior for visible elements in a UI is defined in the UIElement class. This includes the events for keyboard, mouse, touch, drag-drop, and focus interactions. For more info, see Quickstart: Pointers, Responding to keyboard interaction, and Gestures, manipulations, and interactions.

Prominent APIs of UIElement that support input and user interaction:

Gestures and manipulations

Gestures and manipulations are also a way to handle input and user interaction. The APIs are listed out separately here because these events represent how the system interacts with device-level input actions and interprets them as a user interaction. Manipulations are a way to handle dynamic multi-touch interactions such as pinching and stretching. Together, the gestures and manipulations provide the touch patterns for touch interaction with Windows Store apps. For more info, see Gestures, manipulations, and interactions and Touch interaction design.

Prominent APIs of UIElement that support gestures and manipulations:

Basic appearance

The Visibility and Opacity properties are frequently used to adjust the appearance of an element in your UI, especially within styles, templates, and visual states. The Clip, RenderTransform, and Transitions properties are each useful for producing interactions and different looks for your UI elements.

Basic layout

The UIElement class provides a starting point for layout characteristics with properties such as DesiredSize and the Arrange and Measure methods. FrameworkElement adds more layout capabilities. For more info, see Quickstart: Defining layouts and FrameworkElement.

Routed events

Most of the input events of UIElement 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.

Prominent APIs of UIElement that support routed events: AddHandler, RemoveHandler, *Event properties.

Other platform support

UIElement dependency properties

Many of the read-write properties of the UIElement base element class are dependency properties. Dependency properties support some of the basic programming model features for a Windows Store app using C++, C#, or Visual Basic, such as styles and templates, data binding, XAML resource references, and property-changed logic. For more info on dependency properties and the features they support, see Dependency properties overview.

UIElement derived classes

The only Windows Runtime class that derives directly from UIElement is FrameworkElement. For a list of the classes that derive from FrameworkElement, see the "FrameworkElement derived classes" section of the FrameworkElement reference topic.

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml
Windows::UI::Xaml [C++]

Metadata

Windows.winmd

See also

DependencyObject
FrameworkElement
Events and routed events overview
Dependency properties overview

 

 

Mostrar:
© 2014 Microsoft