Framework​Element Class

Definition

Provides a WPF framework-level set of properties, events, and methods for Windows Presentation Foundation (WPF) elements. This class represents the provided WPF framework-level implementation that is built on the WPF core-level APIs that are defined by UIElement.

[System.Windows.Markup.RuntimeNameProperty("Name")]
[System.Windows.Markup.UsableDuringInitialization(true)]
[System.Windows.Markup.XmlLangProperty("Language")]
[System.Windows.StyleTypedProperty(Property="FocusVisualStyle", StyleTargetType=typeof(System.Windows.Controls.Control))]
public class FrameworkElement : System.Windows.UIElement, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.Markup.IQueryAmbient
Inheritance
Derived
Attributes
Implements

Inherited Members

System.Object

System.Windows.DependencyObject

System.Windows.Media.Visual

System.Windows.Threading.DispatcherObject

System.Windows.UIElement

Remarks

FrameworkElement is the connecting point between WPF framework-level element classes and the WPF core-level set of UIElement presentation services. For more information about these concepts, see WPF Architecture.

FrameworkElement extends UIElement and adds the following capabilities:

  • Layout system definition: FrameworkElement provides specific WPF framework-level implementations for certain methods that were defined as virtual members in UIElement. Most notably, FrameworkElement seals certain WPF core-level layout overrides, and instead provides a WPF framework-level equivalent that derived classes should override instead. For example, FrameworkElement seals ArrangeCore but provides ArrangeOverride. These changes reflect the fact that at the WPF framework-level there is a full layout system in place that can render any FrameworkElement derived class. At the WPF core level, certain members that will structure a general WPF based layout solution are in place, but the actual engine of the layout system is not defined. For more information, see Layout.

  • The logical tree: The general WPF programming model is often expressed in terms of being a tree of elements. Support for expressing the tree of elements as a logical tree, and accompanying support for defining that tree in markup is implemented at the FrameworkElement level. Note however that FrameworkElement deliberately does not define a content model, and leaves that responsibility to derived classes. For more information, see Trees in WPF.

  • Object lifetime events: It is often useful to know when an element is initialized (the constructor is called) or when the element is first loaded into a logical tree. FrameworkElement defines several events related to object lifetime that provide useful hooks for code-behind operations that involve elements, such as adding more child elements. For more information, see Object Lifetime Events.

  • Support for data binding and dynamic resource references: The property-level support for data binding and resources is implemented by the DependencyProperty class and embodied in the property system, but the ability to resolve a member value that is stored as an Expression (the programming construct that underlies both data binding and dynamic resources) is implemented by FrameworkElement. For more information, see Data Binding Overview and XAML Resources.

  • Styles: FrameworkElement defines the Style property. However, FrameworkElement does not yet define support for templates, or support decorators. These features are introduced by control classes such as Control and ContentControl.

  • More animation support: Some animation support was already defined at the WPF core level, but FrameworkElement extends this by implementing BeginStoryboard and related members.

As can be seen from the class hierarchy, many WPF classes derive from FrameworkElement, either directly or through intermediate base classes such as Panel or Control.

If you intend to use FrameworkElement as a base class, you might want to first examine the existing derived classes. FrameworkElement provides support for a number of basic scenarios, but also lacks a number of features that are desirable for an "element" in the sense of a building block that you use to create user interface (UI) in Extensible Application Markup Language (XAML). For instance, a FrameworkElement does not define any true content model; FrameworkElement as a base class does not define a property that can create XAML child elements. In particular, you might want to look at Control and ContentControl.

Constructors

Framework​Element()

Initializes a new instance of the FrameworkElement class.

Fields

Actual​Height​Property

Identifies the ActualHeight dependency property.

Actual​Width​Property

Identifies the ActualWidth dependency property.

Binding​Group​Property

Identifies the BindingGroup dependency property.

Context​Menu​Closing​Event

Identifies the ContextMenuClosing routed event.

Context​Menu​Opening​Event

Identifies the ContextMenuOpening routed event.

Context​Menu​Property

Identifies the ContextMenu dependency property.

Cursor​Property

Identifies the Cursor dependency property.

Data​Context​Property

Identifies the DataContext dependency property.

Default​Style​Key​Property

Identifies the DefaultStyleKey dependency property.

Flow​Direction​Property

Identifies the FlowDirection dependency property.

Focus​Visual​Style​Property

Identifies the FocusVisualStyle dependency property.

Force​Cursor​Property

Identifies the ForceCursor dependency property.

Height​Property

Identifies the Height dependency property.

Horizontal​Alignment​Property

Identifies the HorizontalAlignment dependency property.

Input​Scope​Property

Identifies the InputScope dependency property.

Language​Property

Identifies the Language dependency property.

Layout​Transform​Property

Identifies the LayoutTransform dependency property.

Loaded​Event

Identifies the Loaded routed event.

Margin​Property

Identifies the Margin dependency property.

Max​Height​Property

Identifies the MaxHeight dependency property.

Max​Width​Property

Identifies the MaxWidth dependency property.

Min​Height​Property

Identifies the MinHeight dependency property.

Min​Width​Property

Identifies the MinWidth dependency property.

Name​Property

Identifies the Name dependency property.

Overrides​Default​Style​Property

Identifies the OverridesDefaultStyle dependency property.

Request​Bring​Into​View​Event

Identifies the RequestBringIntoView routed event.

Size​Changed​Event

Identifies the SizeChanged routed event.

Style​Property

Identifies the Style dependency property.

Tag​Property

Identifies the Tag dependency property.

Tool​Tip​Closing​Event

Identifies the ToolTipClosing routed event.

Tool​Tip​Opening​Event

Identifies the ToolTipOpening routed event.

Tool​Tip​Property

Identifies the ToolTip dependency property.

Unloaded​Event

Identifies the Unloaded routed event.

Use​Layout​Rounding​Property

Identifies the UseLayoutRounding dependency property.

Vertical​Alignment​Property

Identifies the VerticalAlignment dependency property.

Width​Property

Identifies the Width dependency property.

Properties

Actual​Height

Gets the rendered height of this element.

Actual​Width

Gets the rendered width of this element.

Binding​Group

Gets or sets the BindingGroup that is used for the element.

Context​Menu

Gets or sets the context menu element that should appear whenever the context menu is requested through user interface (UI) from within this element.

Cursor

Gets or sets the cursor that displays when the mouse pointer is over this element.

Data​Context

Gets or sets the data context for an element when it participates in data binding.

Default​Style​Key

Gets or sets the key to use to reference the style for this control, when theme styles are used or defined.

Flow​Direction

Gets or sets the direction that text and other user interface (UI) elements flow within any parent element that controls their layout.

Focus​Visual​Style

Gets or sets a property that enables customization of appearance, effects, or other style characteristics that will apply to this element when it captures keyboard focus.

Force​Cursor

Gets or sets a value that indicates whether this FrameworkElement should force the user interface (UI) to render the cursor as declared by the Cursor property.

Height

Gets or sets the suggested height of the element.

Horizontal​Alignment

Gets or sets the horizontal alignment characteristics applied to this element when it is composed within a parent element, such as a panel or items control.

Inheritance​Behavior

Gets or sets the scope limits for property value inheritance, resource key lookup, and RelativeSource FindAncestor lookup.

Input​Scope

Gets or sets the context for input used by this FrameworkElement.

Is​Initialized

Gets a value that indicates whether this element has been initialized, either during processing by a XAML processor, or by explicitly having its EndInit() method called.

Is​Loaded

Gets a value that indicates whether this element has been loaded for presentation.

Language

Gets or sets localization/globalization language information that applies to an element.

Layout​Transform

Gets or sets a graphics transformation that should apply to this element when layout is performed.

Logical​Children

Gets an enumerator for logical child elements of this element.

Margin

Gets or sets the outer margin of an element.

Max​Height

Gets or sets the maximum height constraint of the element.

Max​Width

Gets or sets the maximum width constraint of the element.

Min​Height

Gets or sets the minimum height constraint of the element.

Min​Width

Gets or sets the minimum width constraint of the element.

Name

Gets or sets the identifying name of the element. The name provides a reference so that code-behind, such as event handler code, can refer to a markup element after it is constructed during processing by a XAML processor.

Overrides​Default​Style

Gets or sets a value that indicates whether this element incorporates style properties from theme styles.

Parent

Gets the logical parent element of this element.

Resources

Gets or sets the locally-defined resource dictionary.

Style

Gets or sets the style used by this element when it is rendered.

Tag

Gets or sets an arbitrary object value that can be used to store custom information about this element.

Templated​Parent

Gets a reference to the template parent of this element. This property is not relevant if the element was not created through a template.

Tool​Tip

Gets or sets the tool-tip object that is displayed for this element in the user interface (UI).

Triggers

Gets the collection of triggers established directly on this element, or in child elements.

Use​Layout​Rounding

Gets or sets a value that indicates whether layout rounding should be applied to this element's size and position during layout.

Vertical​Alignment

Gets or sets the vertical alignment characteristics applied to this element when it is composed within a parent element such as a panel or items control.

Visual​Children​Count

Gets the number of visual child elements within this element.

Width

Gets or sets the width of the element.

Methods

Add​Logical​Child(​Object)

Adds the provided object to the logical tree of this element.

Apply​Template()

Builds the current template's visual tree if necessary, and returns a value that indicates whether the visual tree was rebuilt by this call.

Arrange​Core(​Rect)

Implements ArrangeCore(Rect) (defined as virtual in UIElement) and seals the implementation.

Arrange​Override(​Size)

When overridden in a derived class, positions child elements and determines a size for a FrameworkElement derived class.

Begin​Init()

Starts the initialization process for this element.

Begin​Storyboard(​Storyboard)

Begins the sequence of actions that are contained in the provided storyboard.

Begin​Storyboard(​Storyboard, ​Handoff​Behavior)

Begins the sequence of actions contained in the provided storyboard, with options specified for what should happen if the property is already animated.

Begin​Storyboard(​Storyboard, ​Handoff​Behavior, ​Boolean)

Begins the sequence of actions contained in the provided storyboard, with specified state for control of the animation after it is started.

Bring​Into​View(​Rect)

Attempts to bring the provided region size of this element into view, within any scrollable regions it is contained within.

Bring​Into​View()

Attempts to bring this element into view, within any scrollable regions it is contained within.

End​Init()

Indicates that the initialization process for the element is complete.

Find​Name(​String)

Finds an element that has the provided identifier name.

Find​Resource(​Object)

Searches for a resource with the specified key, and throws an exception if the requested resource is not found.

Get​Binding​Expression(​Dependency​Property)

Returns the BindingExpression that represents the binding on the specified property.

Get​Flow​Direction(​Dependency​Object)

Gets the value of the FlowDirection attached property for the specified DependencyObject.

Get​Layout​Clip(​Size)

Returns a geometry for a clipping mask. The mask applies if the layout system attempts to arrange an element that is larger than the available display space.

Get​Template​Child(​String)

Returns the named element in the visual tree of an instantiated ControlTemplate.

Get​UI​Parent​Core()

Returns an alternative logical parent for this element if there is no visual parent.

Get​Visual​Child(​Int32)

Overrides GetVisualChild(Int32), and returns a child at the specified index from a collection of child elements.

Measure​Core(​Size)

Implements basic measure-pass layout system behavior for FrameworkElement.

Measure​Override(​Size)

When overridden in a derived class, measures the size in layout required for child elements and determines a size for the FrameworkElement-derived class.

Move​Focus(​Traversal​Request)

Moves the keyboard focus away from this element and to another element in a provided traversal direction.

On​Apply​Template()

When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate().

On​Context​Menu​Closing(​Context​Menu​Event​Args)

Invoked whenever an unhandled ContextMenuClosing routed event reaches this class in its route. Implement this method to add class handling for this event.

On​Context​Menu​Opening(​Context​Menu​Event​Args)

Invoked whenever an unhandled ContextMenuOpening routed event reaches this class in its route. Implement this method to add class handling for this event.

On​Got​Focus(​Routed​Event​Args)

Invoked whenever an unhandled GotFocus event reaches this element in its route.

On​Initialized(​Event​Args)

Raises the Initialized event. This method is invoked whenever IsInitialized is set to true internally.

On​Property​Changed(​Dependency​Property​Changed​Event​Args)

Invoked whenever the effective value of any dependency property on this FrameworkElement has been updated. The specific dependency property that changed is reported in the arguments parameter. Overrides OnPropertyChanged(DependencyPropertyChangedEventArgs).

On​Render​Size​Changed(​Size​Changed​Info)

Raises the SizeChanged event, using the specified information as part of the eventual event data.

On​Style​Changed(​Style, ​Style)

Invoked when the style in use on this element changes, which will invalidate the layout.

On​Tool​Tip​Closing(​Tool​Tip​Event​Args)

Invoked whenever an unhandled ToolTipClosing routed event reaches this class in its route. Implement this method to add class handling for this event.

On​Tool​Tip​Opening(​Tool​Tip​Event​Args)

Invoked whenever the ToolTipOpening routed event reaches this class in its route. Implement this method to add class handling for this event.

On​Visual​Parent​Changed(​Dependency​Object)

Invoked when the parent of this element in the visual tree is changed. Overrides OnVisualParentChanged(DependencyObject).

Parent​Layout​Invalidated(​UI​Element)

Supports incremental layout implementations in specialized subclasses of FrameworkElement. ParentLayoutInvalidated(UIElement) is invoked when a child element has invalidated a property that is marked in metadata as affecting the parent's measure or arrange passes during layout.

Predict​Focus(​Focus​Navigation​Direction)

Determines the next element that would receive focus relative to this element for a provided focus movement direction, but does not actually move the focus.

Register​Name(​String, ​Object)

Provides an accessor that simplifies access to the NameScope registration method.

Remove​Logical​Child(​Object)

Removes the provided object from this element's logical tree. FrameworkElement updates the affected logical tree parent pointers to keep in sync with this deletion.

Set​Binding(​Dependency​Property, ​String)

Attaches a binding to this element, based on the provided source property name as a path qualification to the data source.

Set​Binding(​Dependency​Property, ​Binding​Base)

Attaches a binding to this element, based on the provided binding object.

Set​Flow​Direction(​Dependency​Object, ​Flow​Direction)

Sets the value of the FlowDirection attached property for the provided element.

Set​Resource​Reference(​Dependency​Property, ​Object)

Searches for a resource with the specified name and sets up a resource reference to it for the specified property.

Should​Serialize​Resources()

Returns whether serialization processes should serialize the contents of the Resources property.

Should​Serialize​Style()

Returns whether serialization processes should serialize the contents of the Style property.

Should​Serialize​Triggers()

Returns whether serialization processes should serialize the contents of the Triggers property.

Try​Find​Resource(​Object)

Searches for a resource with the specified key, and returns that resource if found.

Unregister​Name(​String)

Simplifies access to the NameScope de-registration method.

Update​Default​Style()

Reapplies the default style to the current FrameworkElement.

Events

Context​Menu​Closing

Occurs just before any context menu on the element is closed.

Context​Menu​Opening

Occurs when any context menu on the element is opened.

Data​Context​Changed

Occurs when the data context for this element changes.

Initialized

Occurs when this FrameworkElement is initialized. This event coincides with cases where the value of the IsInitialized property changes from false (or undefined) to true.

Loaded

Occurs when the element is laid out, rendered, and ready for interaction.

Request​Bring​Into​View

Occurs when BringIntoView(Rect) is called on this element.

Size​Changed

Occurs when either the ActualHeight or the ActualWidth properties change value on this element.

Source​Updated

Occurs when the source value changes for any existing property binding on this element.

Target​Updated

Occurs when the target value changes for any property binding on this element.

Tool​Tip​Closing

Occurs just before any tooltip on the element is closed.

Tool​Tip​Opening

Occurs when any tooltip on the element is opened.

Unloaded

Occurs when the element is removed from within an element tree of loaded elements.

Explicit Interface Implementations

I​Query​Ambient.​Is​Ambient​Property​Available(​String)

For a description of this member, see the IsAmbientPropertyAvailable(String) method.