Skip to content

UIElement class

Base class for elements that support input handling and visibility.

Guide: C# Markup reference: Element

public abstract class UIElement : Element
name description
AllowDrop { get; set; } Gets or sets whether the element accepts drops, taking part in drop-target hit testing and receiving DragEnter, DragOver, DragLeave and Drop.
BackdropFallbackBrush { get; set; } Gets or sets the brush drawn in place of the backdrop where what is behind the element cannot be read; null draws nothing there.
BackdropFilter { get; set; } Gets or sets the filter applied to what is drawn behind the element, such as a blur for frosted glass. The element’s own background and content are drawn over the result.
CacheMode { get; set; } Gets or sets how this element’s rendering is cached, or null for no cache.
CanDrag { get; set; } Gets or sets whether the element initiates drag sessions via a mouse gesture.
Cursor { get; set; } Gets or sets the cursor shown while the mouse is over this element; null inherits from the parent or the platform default, and None hides the cursor.
Focusable { get; set; } Gets or sets whether this element can receive keyboard focus.
IsEffectivelyEnabled { get; } Gets whether this element and every ancestor are enabled; input and the disabled appearance follow this, not IsEnabled.
IsEnabled { get; set; } Gets or sets whether the element is enabled for input.
IsFocused { get; } Gets whether the element has keyboard focus.
IsFocusWithin { get; } Gets whether this element or any of its descendants has keyboard focus.
IsHitTestVisible { get; set; } Gets or sets whether the element participates in hit testing.
IsMouseCaptured { get; } Gets whether this element has mouse capture.
IsMouseOver { get; } Gets whether the mouse is over this element.
IsTabStop { get; set; } Gets or sets whether the element participates in Tab traversal.
IsVisible { get; set; } Gets or sets whether the element is visible.
Opacity { get; set; } Gets or sets the opacity of the element and its subtree, from 0 to 1.
SkipViewportCull { get; set; } Gets or sets whether the element is drawn even when it lies outside the viewport; inherited by descendants.
TabIndex { get; set; } Gets or sets the position in the Tab order.
Transitions { get; set; } Gets or sets the transitions owned by this element; the list is snapshotted on assignment, so assign a new list to change the set.
Triggers { get; set; } Gets or sets the conditional values owned by this element; the list is snapshotted and validated on assignment, so assign a new list to change the set.
event DragCompleted Occurs once a drag session originating from this element has ended (drop, reject, or cancel).
event DragEnter Occurs when a drag enters the element’s hit-test bounds.
event DragLeave Occurs when a drag leaves the element’s hit-test bounds.
event DragOver Occurs while a drag is over the element.
event DragStarting Occurs after a drag gesture is detected on this element; handlers populate Data and AllowedEffects to start the session, or set Cancel.
event Drop Occurs when data is dropped onto the element.
event GotFocus Occurs when the element receives keyboard focus.
event KeyDown Occurs when a key is pressed while the element has focus; marking it handled also drops the text input the keystroke would produce.
event KeyUp Occurs when a key is released while the element has focus.
event LostFocus Occurs when the element loses keyboard focus.
event MouseDoubleClick Occurs when the user double-clicks a mouse button over the element.
event MouseDown Occurs when a mouse button is pressed over the element.
event MouseEnter Occurs when the mouse enters the element.
event MouseLeave Occurs when the mouse leaves the element.
event MouseMove Occurs when the mouse moves over the element.
event MouseUp Occurs when a mouse button is released over the element.
event MouseWheel Occurs when the mouse wheel is scrolled over the element.
BeginDrag(…) Starts a drag session from this element without gesture detection; the outcome is reported through DragCompleted, and nothing happens while the element is not in a window.
Focus() Attempts to focus this element.
GetAutomationPeer() Gets the element’s automation peer, creating it on first use; null when automation is off or the element has none.
HitTest(…) Performs hit testing to find the element at the specified point.
override InvalidateVisual()
InvalidateVisualState() Queues this element for visual-state reconciliation at the start of the next layout pass; call it when a property that feeds ComputeVisualState changes.
PointFromScreen(…) Converts a point from screen coordinates in device pixels to element coordinates in DIPs.
PointToScreen(…) Converts a point from element coordinates in DIPs to screen coordinates in device pixels.
RectFromScreen(…) Converts a rectangle from screen coordinates in device pixels to element coordinates in DIPs.
RectToScreen(…) Converts a rectangle from element coordinates in DIPs to screen coordinates in device pixels.
Render(…) Renders the element and its subtree unless it is invisible, fully transparent or outside the viewport.
static readonly AllowDropProperty Whether the element accepts drops; see AllowDrop for what the platform delivers.
static readonly BackdropFallbackBrushProperty The brush that fills the backdrop’s place where what is drawn behind the element cannot be read; null leaves it empty.
static readonly BackdropFilterProperty The filter applied to what is drawn behind the element, inside its layout box and cut to its corners; the filter’s source input is those pixels. Null draws no backdrop.
static readonly CacheModeProperty The render-cache policy; a BitmapCache captures the element’s output into an offscreen bitmap reused until its content, size or DPI changes, and null (the default) renders live.
static readonly CanDragProperty Whether a press-and-drag gesture on this element raises DragStarting.
static readonly CursorProperty The cursor shown while the mouse is over this element; null inherits from the parent or the platform default, and None hides the cursor.
static readonly FocusableProperty Whether the element can receive keyboard focus.
static readonly IsEffectivelyEnabledProperty Whether this element and every ancestor are enabled; read-only, derived from IsEnabled and the parent chain.
static readonly IsEnabledProperty Whether the element is enabled for user interaction.
static readonly IsFocusedProperty Whether the element has keyboard focus; read-only, set by FocusManager.
static readonly IsFocusWithinProperty Whether this element or any of its descendants has keyboard focus; read-only, derived from the focus chain.
static readonly IsHitTestVisibleProperty Whether the element participates in hit testing.
static readonly IsMouseCapturedProperty Whether this element has mouse capture; read-only, set via CaptureMouse.
static readonly IsMouseOverProperty Whether the mouse is over this element; read-only, set by the input router.
static readonly IsTabStopProperty Whether a focusable element is in the Tab order; false removes it from Tab traversal only, leaving click and programmatic focus unaffected.
static readonly IsVisibleProperty Whether the element is rendered and takes part in layout.
static readonly OpacityProperty The opacity of the element and everything under it, from 0 (invisible) to 1 (opaque); it affects neither layout nor hit testing, so a fully transparent element still occupies its box and takes the pointer.
static readonly SkipViewportCullProperty Whether the element is drawn even when it lies outside the viewport; inherited by descendants.
static readonly TabIndexProperty The position in the Tab order; non-negative finite values are visited ascending before elements without one, and NaN (the default), negative and infinite values keep tree order.