Class FrameworkElement
Provides a framework of common APIs for objects that participate in UI and programmatic layout. FrameworkElement also defines APIs related to data binding, object tree, and object lifetime feature areas.
Inheritance
Inherited Members
Namespace: System.Windows
Assembly: OpenSilver.dll
Syntax
public abstract class FrameworkElement : UIElement, IFrameworkElement, IUIElement, IDependencyObject
Constructors
| Improve this Doc View SourceFrameworkElement()
Provides base class initialization behavior for FrameworkElement-derived classes.
Declaration
public FrameworkElement()
Fields
| Improve this Doc View SourceActualHeightProperty
Identifies the ActualHeight dependency property.
Declaration
public static readonly DependencyProperty ActualHeightProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ActualWidthProperty
Identifies the ActualWidth dependency property.
Declaration
public static readonly DependencyProperty ActualWidthProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ContextMenuProperty
Identifies the ContextMenu dependency property.
Declaration
public static readonly DependencyProperty ContextMenuProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
CursorProperty
Identifies the Cursor dependency property.
Declaration
public static readonly DependencyProperty CursorProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
DataContextProperty
Identifies the DataContext dependency property.
Declaration
public static readonly DependencyProperty DataContextProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
DefaultStyleKeyProperty
Identifies the DefaultStyleKey dependency property.
Declaration
public static readonly DependencyProperty DefaultStyleKeyProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
FlowDirectionProperty
Identifies the FlowDirection dependency property.
Declaration
public static readonly DependencyProperty FlowDirectionProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
HeightProperty
Identifies the Height dependency property.
Declaration
public static readonly DependencyProperty HeightProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
HorizontalAlignmentProperty
Identifies the HorizontalAlignment dependency property.
Declaration
public static readonly DependencyProperty HorizontalAlignmentProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
LanguageProperty
Identifies the Language dependency property.
Declaration
public static readonly DependencyProperty LanguageProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
LoadedEvent
Declaration
public static readonly RoutedEvent LoadedEvent
Field Value
Type | Description |
---|---|
RoutedEvent |
MarginProperty
Identifies the Margin dependency property.
Declaration
public static readonly DependencyProperty MarginProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
MaxHeightProperty
Identifies the MaxHeight dependency property.
Declaration
public static readonly DependencyProperty MaxHeightProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
MaxWidthProperty
Identifies the MaxWidth dependency property.
Declaration
public static readonly DependencyProperty MaxWidthProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
MinHeightProperty
Identifies the MinHeight dependency property.
Declaration
public static readonly DependencyProperty MinHeightProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
MinWidthProperty
Identifies the MinWidth dependency property.
Declaration
public static readonly DependencyProperty MinWidthProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
NameProperty
Identifies the Name dependency property.
Declaration
public static readonly DependencyProperty NameProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
OverridesDefaultStyleProperty
Identifies the OverridesDefaultStyle dependency property.
Declaration
public static readonly DependencyProperty OverridesDefaultStyleProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
StyleProperty
Identifies the Style dependency property.
Declaration
public static readonly DependencyProperty StyleProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
TagProperty
Identifies the Tag dependency property.
Declaration
public static readonly DependencyProperty TagProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ToolTipProperty
Identifies the ToolTip dependency property.
Declaration
public static readonly DependencyProperty ToolTipProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
VerticalAlignmentProperty
Identifies the VerticalAlignment dependency property.
Declaration
public static readonly DependencyProperty VerticalAlignmentProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
WidthProperty
Identifies the Width dependency property.
Declaration
public static readonly DependencyProperty WidthProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
Properties
| Improve this Doc View SourceActualHeight
Gets the rendered height of a FrameworkElement.
Declaration
public double ActualHeight { get; }
Property Value
Type | Description |
---|---|
System.Double | The height, in pixels, of the object. The default is 0. The default might be encountered if the object has not been loaded and undergone a layout pass. |
ActualWidth
Gets the rendered width of a FrameworkElement.
Declaration
public double ActualWidth { get; }
Property Value
Type | Description |
---|---|
System.Double | The width, in pixels, of the object. The default is 0. The default might be encountered if the object has not been loaded and undergone a layout pass. |
ContextMenu
Gets or sets the context menu element that should appear whenever the context menu is requested through user interface (UI) from within this element.
Declaration
public ContextMenu ContextMenu { get; set; }
Property Value
Type | Description |
---|---|
ContextMenu | The context menu assigned to this element. |
Cursor
Gets or sets the cursor that displays when the mouse pointer is over this element.
Declaration
public Cursor Cursor { get; set; }
Property Value
Type | Description |
---|---|
Cursor |
DataContext
Gets or sets the data context for a FrameworkElement when it participates in data binding.
Declaration
public object DataContext { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
DefaultStyleKey
Gets or sets the key that references the default style for the control.
Declaration
protected object DefaultStyleKey { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
FlowDirection
Gets or sets the direction that text and other user interface elements flow within any parent element that controls their layout.
Declaration
public FlowDirection FlowDirection { get; set; }
Property Value
Type | Description |
---|---|
FlowDirection | The direction that text and other UI elements flow within their parent element, as a value of the enumeration. The default value is LeftToRight. |
Height
Gets or sets the suggested height of a FrameworkElement.
Declaration
[TypeConverter(typeof(LengthConverter))]
public double Height { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The height, in pixels, of the object. The default is System.Double.NaN. Except for the special System.Double.NaN value, this value must be equal to or greater than 0. |
HorizontalAlignment
Gets or sets the horizontal alignment characteristics that are applied to a FrameworkElement when it is composed in a layout parent, such as a panel or items control.
Declaration
public HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
Type | Description |
---|---|
HorizontalAlignment |
IsLoaded
Gets a value that indicates whether this element is in the Visual Tree, that is, if it has been loaded for presentation.
Declaration
public bool IsLoaded { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Language
Gets or sets localization/globalization language information that applies to a FrameworkElement.
Declaration
[TypeConverter(typeof(XmlLanguageConverter))]
public XmlLanguage Language { get; set; }
Property Value
Type | Description |
---|---|
XmlLanguage | The language information for this object. The default is an XmlLanguage object that has its IetfLanguageTag value set to the string "en-US". |
LogicalChildren
Gets an enumerator for logical child elements of this element.
Declaration
protected virtual IEnumerator LogicalChildren { get; }
Property Value
Type | Description |
---|---|
System.Collections.IEnumerator | An enumerator for logical child elements of this element. |
Margin
Gets or sets the outer margin of a FrameworkElement.
Declaration
public Thickness Margin { get; set; }
Property Value
Type | Description |
---|---|
Thickness |
MaxHeight
Gets or sets the maximum height constraint of a FrameworkElement.
Declaration
public double MaxHeight { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
MaxWidth
Gets or sets the maximum width constraint of a FrameworkElement.
Declaration
public double MaxWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
MinHeight
Gets or sets the minimum height constraint of a FrameworkElement.
Declaration
public double MinHeight { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
MinWidth
Gets or sets the minimum width constraint of a FrameworkElement.
Declaration
public double MinWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Name
Gets or sets the identifying name of the object. When a XAML processor creates the object tree from XAML markup, run-time code can refer to the XAML-declared object by this name.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
OverridesDefaultStyle
Gets or sets a value that indicates whether this element incorporates style properties from theme styles.
Declaration
public bool OverridesDefaultStyle { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true if this element does not use theme style properties; all style-originating properties come from local application styles, and theme style properties do not apply. false if application styles apply first, and then theme styles apply for properties that were not specifically set in application styles. The default is false. |
Parent
Gets the parent object of this FrameworkElement in the object tree.
Declaration
public DependencyObject Parent { get; }
Property Value
Type | Description |
---|---|
DependencyObject |
ResourceLookupMode
Indicates the current mode of lookup for resources.
Declaration
public InheritanceBehavior ResourceLookupMode { get; set; }
Property Value
Type | Description |
---|---|
InheritanceBehavior |
Resources
Gets the locally defined resource dictionary. In XAML, you can establish resource items as child object elements of a frameworkElement.Resources property element, through XAML implicit collection syntax.
Declaration
public ResourceDictionary Resources { get; set; }
Property Value
Type | Description |
---|---|
ResourceDictionary |
Style
Gets or sets an instance Style that is applied for this object during rendering.
Declaration
public Style Style { get; set; }
Property Value
Type | Description |
---|---|
Style |
Tag
Gets or sets an arbitrary object value that can be used to store custom information about this object.
Declaration
public object Tag { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
TemplatedParent
Gets a reference to the template parent of this element. This property is not relevant if the element was not created through a template.
Declaration
public DependencyObject TemplatedParent { get; }
Property Value
Type | Description |
---|---|
DependencyObject | The element whose FrameworkTemplate caused this element to be created. This value is frequently null. |
ToolTip
Gets or sets the tool-tip object that is displayed for this element in the user interface (UI).
Declaration
public object ToolTip { get; set; }
Property Value
Type | Description |
---|---|
System.Object | The tooltip object. |
Triggers
Gets the collection of triggers for animations that are defined for a FrameworkElement.
Declaration
public TriggerCollection Triggers { get; }
Property Value
Type | Description |
---|---|
TriggerCollection | The collection of triggers for animations that are defined for this object. |
VerticalAlignment
Gets or sets the vertical alignment characteristics that are applied to a FrameworkElement when it is composed in a parent object such as a panel or items control.
Declaration
public VerticalAlignment VerticalAlignment { get; set; }
Property Value
Type | Description |
---|---|
VerticalAlignment |
VisualChildrenCount
Gets the number of visual child elements within this element.
Declaration
protected override int VisualChildrenCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The number of visual child elements for this element. |
Overrides
| Improve this Doc View SourceWidth
Gets or sets the width of a FrameworkElement.
Declaration
[TypeConverter(typeof(LengthConverter))]
public double Width { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The width of the object, in pixels. The default is System.Double.NaN. Except for the special System.Double.NaN value, this value must be equal to or greater than 0. |
Methods
| Improve this Doc View SourceAddLogicalChild(Object)
Adds the provided object to the logical tree of this element.
Declaration
protected void AddLogicalChild(object child)
Parameters
Type | Name | Description |
---|---|---|
System.Object | child | Child element to be added. |
ArrangeOverride(Size)
Provides the behavior for the Arrange pass of Silverlight layout. Classes can override this method to define their own Arrange pass behavior.
Declaration
protected virtual Size ArrangeOverride(Size finalSize)
Parameters
Type | Name | Description |
---|---|---|
Size | finalSize | The final area within the parent that this object should use to arrange itself and its children. |
Returns
Type | Description |
---|---|
Size | The actual size that is used after the element is arranged in layout. |
CreateDomElement(Object, out Object)
Provides a base implementation for creating the dom elements designed to represent an instance of a FrameworkElement and defines the place where its child(ren) will be added.
Declaration
public override object CreateDomElement(object parentRef, out object domElementWhereToPlaceChildren)
Parameters
Type | Name | Description |
---|---|---|
System.Object | parentRef | The parent of the FrameworkElement |
System.Object | domElementWhereToPlaceChildren | The dom element where the FrameworkElement's children will be added. |
Returns
Type | Description |
---|---|
System.Object | The "root" dom element of the FrameworkElement. |
Overrides
| Improve this Doc View SourceFindName(String)
Retrieves an object that has the specified identifier name.
Declaration
public object FindName(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the requested object. |
Returns
Type | Description |
---|---|
System.Object | The requested object. This can be null if no matching object was found in the current XAML namescope. |
GetBindingExpression(DependencyProperty)
Retrieves the BindingExpression for a dependency property where a binding is established.
Declaration
public BindingExpression GetBindingExpression(DependencyProperty dp)
Parameters
Type | Name | Description |
---|---|---|
DependencyProperty | dp | The dependency property identifier for the specific property on this FrameworkElement where you want to obtain the BindingExpression. |
Returns
Type | Description |
---|---|
BindingExpression | A BindingExpression for the binding, if the local value represented a data-bound value. May return null if the property is not a data-bound value. |
GetVisualChild(Int32)
Overrides GetVisualChild(Int32), and returns a child at the specified index from a collection of child elements.
Declaration
protected override UIElement GetVisualChild(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the requested child element in the collection. |
Returns
Type | Description |
---|---|
UIElement | The requested child element. This should not return null; if the provided index is out of range, an exception is thrown. |
Overrides
| Improve this Doc View SourceINTERNAL_OnAttachedToVisualTree()
Declaration
protected override void INTERNAL_OnAttachedToVisualTree()
Overrides
| Improve this Doc View SourceINTERNAL_OnDetachedFromVisualTree()
Declaration
protected override void INTERNAL_OnDetachedFromVisualTree()
Overrides
| Improve this Doc View SourceManageIsEnabled(Boolean)
Declaration
protected override void ManageIsEnabled(bool isEnabled)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isEnabled |
Overrides
| Improve this Doc View SourceMeasureOverride(Size)
Provides the behavior for the Measure pass of Silverlight layout. Classes can override this method to define their own Measure pass behavior.
Declaration
protected virtual Size MeasureOverride(Size availableSize)
Parameters
Type | Name | Description |
---|---|---|
Size | availableSize | The available size that this object can give to child objects. Infinity (System.Double.PositiveInfinity) can be specified as a value to indicate that the object will size to whatever content is available. |
Returns
Type | Description |
---|---|
Size | The size that this object determines it needs during layout, based on its calculations of the allocated sizes for child objects; or based on other considerations, such as a fixed container size. |
OnApplyTemplate()
Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.
Declaration
public virtual void OnApplyTemplate()
OnPropertyChanged(DependencyPropertyChangedEventArgs)
Invoked whenever the effective value of any dependency property on this DependencyObject has been updated. The specific dependency property that changed is reported in the event data.
Declaration
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
DependencyPropertyChangedEventArgs | e | Event data that will contain the dependency property identifier of interest, the property metadata for the type, and old and new values. |
Overrides
| Improve this Doc View SourceOnVisualParentChanged(DependencyObject)
Invoked when the parent of this element in the visual tree is changed. Overrides OnVisualParentChanged(DependencyObject).
Declaration
protected override void OnVisualParentChanged(DependencyObject oldParent)
Parameters
Type | Name | Description |
---|---|---|
DependencyObject | oldParent | The old parent element. May be null to indicate that the element did not have a visual parent previously. |
Overrides
| Improve this Doc View SourceRemoveLogicalChild(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.
Declaration
protected void RemoveLogicalChild(object child)
Parameters
Type | Name | Description |
---|---|---|
System.Object | child | The element to remove. |
SetBinding(DependencyProperty, Binding)
Attaches a binding to a FrameworkElement, using the provided binding object, and returns a BindingExpression for possible later use.
Declaration
public BindingExpression SetBinding(DependencyProperty dependencyProperty, Binding binding)
Parameters
Type | Name | Description |
---|---|---|
DependencyProperty | dependencyProperty | The dependency property identifier of the property that is data bound. |
Binding | binding | The binding to use for the property. |
Returns
Type | Description |
---|---|
BindingExpression | A BindingExpression object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | binding is specified as TwoWay, but has an empty Path. or dp or binding parameters are null. |
SetBinding(DependencyProperty, BindingBase)
Attaches a binding to this element, based on the provided binding object.
Declaration
public BindingExpressionBase SetBinding(DependencyProperty dp, BindingBase binding)
Parameters
Type | Name | Description |
---|---|---|
DependencyProperty | dp | Identifies the property where the binding should be established. |
BindingBase | binding | Represents the specifics of the data binding. |
Returns
Type | Description |
---|---|
BindingExpressionBase | Records the conditions of the binding. This return value can be useful for error checking. |
Events
| Improve this Doc View SourceBindingValidationError
Occurs when a data validation error is reported by a binding source.
Declaration
public event EventHandler<ValidationErrorEventArgs> BindingValidationError
Event Type
Type | Description |
---|---|
System.EventHandler<ValidationErrorEventArgs> |
ContextMenuOpening
Occurs when any context menu on the element is opened.
Declaration
public event ContextMenuEventHandler ContextMenuOpening
Event Type
Type | Description |
---|---|
ContextMenuEventHandler |
DataContextChanged
Occurs when the data context for this element changes.
Declaration
public event DependencyPropertyChangedEventHandler DataContextChanged
Event Type
Type | Description |
---|---|
DependencyPropertyChangedEventHandler |
LayoutUpdated
Occurs when the layout of the Silverlight visual tree changes.
Declaration
public event EventHandler LayoutUpdated
Event Type
Type | Description |
---|---|
System.EventHandler |
Loaded
Occurs when a FrameworkElement has been constructed and added to the object tree.
Declaration
public event RoutedEventHandler Loaded
Event Type
Type | Description |
---|---|
RoutedEventHandler |
SizeChanged
Occurs when either the ActualHeight or the ActualWidth properties change value on a FrameworkElement.
Declaration
public event SizeChangedEventHandler SizeChanged
Event Type
Type | Description |
---|---|
SizeChangedEventHandler |
Unloaded
Occurs when this object is no longer connected to the main object tree.
Declaration
public event RoutedEventHandler Unloaded
Event Type
Type | Description |
---|---|
RoutedEventHandler |