This documentation is archived and is not being maintained.

UIElement Class

Updated: July 2008

UIElement is a base class for WPF core level implementations building on Windows Presentation Foundation (WPF) elements and basic presentation characteristics.

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)

public class UIElement : Visual, IAnimatable, 
<UIElement .../>

UIElement provides a starting point for element layout characteristics, and also exposes virtual methods that derived classes can override, which can influence the layout rendering behavior of the element and its child elements.

Much of the input and focusing behavior for elements in general is also defined in the UIElement class. This includes the events for keyboard, mouse and stylus input, and related status properties. Many of these events are routed events, and many of the input-related events have both a bubbling routing version as well as a tunneling version of the event. These paired events are typically the events of greatest interest to control authors.

UIElement also includes APIs that relate to the WPF event model, including methods that can raise specified routed events that are sourced from an element instance.

In terms of architecture, UIElement can be considered roughly equivalent to a window handle in Win32 programming, or an Element in Dynamic HTML (DHTML) programming. UIElement is a base element at the WPF core level.

A UIElement has the following capabilities that are specifically defined by the UIElement class:

  • Can render as a child element (UIElement derives from Visual, a high level graphics class)

  • Contains logic that is used to size and position possible child elements of a UIElement (when interpreted by a layout system)

  • Can respond to user input (including control of where input is getting sent to via their handling of event routing, or routing of commands)

  • Can raise routed events that travel a route through the logical element tree

  • Supports some aspects of the animation system

FrameworkElement is the WPF framework-level implementation class that builds on UIElement, and adds specific interactions with the WPF framework level. FrameworkElement adds and defines the following capabilities:

  • Additional framework-specific layout characteristics

  • Support for richer metadata reporting on properties

  • Class-specific implementation of certain input base classes and their attached properties or attached events

  • Style support

  • Further animation support

Another related class is ContentElement. The ContentElement class implements many of the same members as does UIElement; the difference between these two classes has to do with their intended place in the overall content model. A UIElement derived class typically defines a relatively rigid content model, meaning that there are restrictions on what elements may be child elements in markup. There might be capacity for taking less restrictive child content in a UIElement, but that capacity is typically centralized in designated content properties. A ContentElement derived class is typically not as restrictive about content, to support scenarios such as flow-format documents.

Important noteImportant Note:

Visibility state affects all input handling by that element. Elements that are not visible do not participate in hit testing and do not receive input events, even if the mouse is over the bounds where the element would be if were visible.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0




July 2008

Added new members: Effect property, Uid property, EffectProperty field, UidProperty field.

SP1 feature change.