Show / Hide Table of Contents

    Class UIElement

    Inheritance
    Object
    DispatcherObject
    UIElement
    Control
    Image
    InkCanvas
    Panel
    Text
    TextFlow
    Shape
    Inherited Members
    DispatcherObject.CheckAccess()
    DispatcherObject.VerifyAccess()
    DispatcherObject.Dispatcher
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: nanoFramework.Presentation
    Assembly: nanoFramework.Graphics.dll
    Syntax
    public abstract class UIElement : DispatcherObject

    Constructors

    | Improve this Doc View Source

    UIElement()

    Declaration
    protected UIElement()

    Fields

    | Improve this Doc View Source

    _horizontalAlignment

    Declaration
    protected HorizontalAlignment _horizontalAlignment
    Field Value
    Type Description
    HorizontalAlignment
    | Improve this Doc View Source

    _verticalAlignment

    Declaration
    protected VerticalAlignment _verticalAlignment
    Field Value
    Type Description
    VerticalAlignment

    Properties

    | Improve this Doc View Source

    ActualHeight

    Declaration
    public int ActualHeight { get; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    ActualWidth

    Declaration
    public int ActualWidth { get; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    Height

    Declaration
    public int Height { get; set; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    HorizontalAlignment

    Declaration
    public HorizontalAlignment HorizontalAlignment { get; set; }
    Property Value
    Type Description
    HorizontalAlignment
    | Improve this Doc View Source

    InstanceEventHandlersStore

    Ensure the store has been created.

    Declaration
    protected Hashtable InstanceEventHandlersStore { get; }
    Property Value
    Type Description
    Hashtable
    | Improve this Doc View Source

    IsArrangeValid

    Determines if the RenderSize and position of child elements is valid.

    Declaration
    public bool IsArrangeValid { get; }
    Property Value
    Type Description
    Boolean
    Remarks

    A developer can force arrangement to be invalidated by calling InvalidateArrange. IsArrangeValid and IsMeasureValid are related, in that arrangement cannot be valid without measurement first being valid.

    | Improve this Doc View Source

    IsEnabled

    Fetches the value of the IsEnabled property

    Declaration
    public bool IsEnabled { get; set; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    IsFocused

    A property indicating if the button is focused on this element or not.

    Declaration
    public bool IsFocused { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    IsMeasureValid

    Determines if the DesiredSize is valid.

    Declaration
    public bool IsMeasureValid { get; }
    Property Value
    Type Description
    Boolean
    Remarks

    A developer can force arrangement to be invalidated by calling InvalidateMeasure. IsArrangeValid and IsMeasureValid are related, in that arrangement cannot be valid without measurement first being valid.

    | Improve this Doc View Source

    IsVisible

    A property indicating if this element is Visible or not.

    Declaration
    public bool IsVisible { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    LogicalChildren

    Declaration
    protected UIElementCollection LogicalChildren { get; }
    Property Value
    Type Description
    UIElementCollection
    | Improve this Doc View Source

    Parent

    Declaration
    public UIElement Parent { get; }
    Property Value
    Type Description
    UIElement
    | Improve this Doc View Source

    RootUIElement

    Declaration
    public UIElement RootUIElement { get; }
    Property Value
    Type Description
    UIElement
    | Improve this Doc View Source

    VerticalAlignment

    Declaration
    public VerticalAlignment VerticalAlignment { get; set; }
    Property Value
    Type Description
    VerticalAlignment
    | Improve this Doc View Source

    Visibility

    Visibility accessor

    Declaration
    public Visibility Visibility { get; set; }
    Property Value
    Type Description
    Visibility
    | Improve this Doc View Source

    Width

    Declaration
    public int Width { get; set; }
    Property Value
    Type Description
    Int32

    Methods

    | Improve this Doc View Source

    AddHandler(RoutedEvent, RoutedEventHandler, Boolean)

    Adds a routed event handler for the particular RoutedEvent

    Declaration
    public void AddHandler(RoutedEvent routedEvent, RoutedEventHandler handler, bool handledEventsToo)
    Parameters
    Type Name Description
    RoutedEvent routedEvent

    RoutedEvent for which the handler is attached

    RoutedEventHandler handler

    The handler that will be invoked on this object when the RoutedEvent is raised

    Boolean handledEventsToo

    Flag indicating whether or not the listener wants to hear about events that have already been handled

    Remarks

    The handler added thus is also known as an instance handler

    NOTE: It is not an error to add a handler twice (handler will simply be called twice)

    Input parameters RoutedEvent and handler cannot be null

    handledEventsToo input parameter when false means that listener does not care about already handled events. Hence the handler will not be invoked on the target if the RoutedEvent has already been Handled

    handledEventsToo input parameter when true means that the listener wants to hear about all events even if they have already been handled. Hence the handler will be invoked irrespective of the event being Handled

    | Improve this Doc View Source

    AddToEventRoute(EventRoute, RoutedEventArgs)

    Add the event handlers for this element to the route.

    Declaration
    public void AddToEventRoute(EventRoute route, RoutedEventArgs args)
    Parameters
    Type Name Description
    EventRoute route
    RoutedEventArgs args
    | Improve this Doc View Source

    Arrange(Int32, Int32, Int32, Int32)

    Parents or system call this method to arrange the internals of children on a second pass of layout update.

    Declaration
    public void Arrange(int finalRectX, int finalRectY, int finalRectWidth, int finalRectHeight)
    Parameters
    Type Name Description
    Int32 finalRectX

    This is the final X location that parent or system wants this UIElement to assume.

    Int32 finalRectY

    This is the final Y location that parent or system wants this UIElement to assume.

    Int32 finalRectWidth

    This is the Width that parent or system wants this UIElement to assume.

    Int32 finalRectHeight

    This is the height that parent or system wants this UIElement to assume.

    Remarks

    This method internally calls ArrangeOverride override, giving the derived class opportunity to arrange its children and/or content using final computed size. In their ArrangeOverride overrides, derived class is supposed to create its visual structure and prepare itself for rendering. Arrange is called by parents from their implementation of ArrangeOverride or by system when needed. This method sets Bounds=finalSize before calling ArrangeOverride.

    | Improve this Doc View Source

    ArrangeOverride(Int32, Int32)

    ArrangeOverride allows for the customization of the final sizing and positioning of children.

    Declaration
    protected virtual void ArrangeOverride(int arrangeWidth, int arrangeHeight)
    Parameters
    Type Name Description
    Int32 arrangeWidth

    Final width

    Int32 arrangeHeight

    Final height

    Remarks

    UIElement authors should override this method, call Arrange on each visible child UIElement, to size and position each child UIElement by passing a rectangle reserved for the child within parent space. Note: It is required that a parent UIElement calls Arrange on each child or they won't be rendered. Typical override follows a pattern roughly like this (pseudo-code):

    protected override void ArrangeOverride(int arrangeWidth, int arrangeHeight)
    {
    
    foreach (UIElement child in VisualChildren)
    {
        child.Arrange(new Rect(childX, childY, childWidth, childHeight);
    }
    }
    | Improve this Doc View Source

    ChildElementFromPoint(Int32, Int32)

    Given x, y co-ordinates of the parent UIElement, find the child control that is directly underneath that point. If there are multiple such controls, the one that was created/inserted into the list last wins. This is because we don't have explicit z-ordering right now.

    Declaration
    public UIElement ChildElementFromPoint(int x, int y)
    Parameters
    Type Name Description
    Int32 x
    Int32 y
    Returns
    Type Description
    UIElement
    | Improve this Doc View Source

    ContainsPoint(Int32, Int32)

    Declaration
    public bool ContainsPoint(int x, int y)
    Parameters
    Type Name Description
    Int32 x
    Int32 y
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    GetDesiredSize(out Int32, out Int32)

    Declaration
    public void GetDesiredSize(out int width, out int height)
    Parameters
    Type Name Description
    Int32 width
    Int32 height
    | Improve this Doc View Source

    GetLayoutOffset(out Int32, out Int32)

    Declaration
    public void GetLayoutOffset(out int x, out int y)
    Parameters
    Type Name Description
    Int32 x
    Int32 y
    | Improve this Doc View Source

    GetMargin(out Int32, out Int32, out Int32, out Int32)

    Declaration
    public void GetMargin(out int left, out int top, out int right, out int bottom)
    Parameters
    Type Name Description
    Int32 left
    Int32 top
    Int32 right
    Int32 bottom
    | Improve this Doc View Source

    GetPointerTarget(Int32, Int32)

    Declaration
    public UIElement GetPointerTarget(int x, int y)
    Parameters
    Type Name Description
    Int32 x
    Int32 y
    Returns
    Type Description
    UIElement
    | Improve this Doc View Source

    GetRenderSize(out Int32, out Int32)

    Declaration
    public void GetRenderSize(out int width, out int height)
    Parameters
    Type Name Description
    Int32 width
    Int32 height
    | Improve this Doc View Source

    GetUnclippedSize(out Int32, out Int32)

    Declaration
    public void GetUnclippedSize(out int width, out int height)
    Parameters
    Type Name Description
    Int32 width
    Int32 height
    | Improve this Doc View Source

    Invalidate()

    Declaration
    public void Invalidate()
    | Improve this Doc View Source

    InvalidateArrange()

    Invalidates the arrange state for the UIElement. The UIElement will be queued for an update layout that will occur asynchronously. MeasureOverride will not be called unless InvalidateMeasure is also called - or that something else caused the measure state to be invalidated.

    Declaration
    public void InvalidateArrange()
    | Improve this Doc View Source

    InvalidateMeasure()

    Invalidates the measurement state for the UIElement. This has the effect of also invalidating the arrange state for the UIElement. The UIElement will be queued for an update layout that will occur asynchronously.

    Declaration
    public void InvalidateMeasure()
    | Improve this Doc View Source

    InvalidateRect(Int32, Int32, Int32, Int32)

    Declaration
    public void InvalidateRect(int x, int y, int w, int h)
    Parameters
    Type Name Description
    Int32 x
    Int32 y
    Int32 w
    Int32 h
    | Improve this Doc View Source

    Measure(Int32, Int32)

    Updates DesiredSize of the UIElement. Must be called by parents from their MeasureOverride, to form recursive update. This is first pass of layout update.

    Declaration
    public void Measure(int availableWidth, int availableHeight)
    Parameters
    Type Name Description
    Int32 availableWidth

    Available width that parent can give to the child. May be MaxValue (when parent wants to measure to content). This is soft constraint. Child can return bigger size to indicate that it wants bigger space and hope that parent can throw in scrolling...

    Int32 availableHeight

    Available height that parent can give to the child. May be MaxValue (when parent wants to measure to content). This is soft constraint. Child can return bigger size to indicate that it wants bigger space and hope that parent can throw in scrolling...

    Remarks

    Measure is called by parents on their children. Internally, Measure calls MeasureOverride override on the same object, giving it opportunity to compute its DesiredSize.

    This method will return immediately if child is not Dirty, previously measured and availableSize is the same as cached.

    This method also resets the IsMeasureinvalid bit on the child.

    In case when "unbounded measure to content" is needed, parent can use availableSize as double.PositiveInfinity. Any returned size is OK in this case.

    | Improve this Doc View Source

    MeasureOverride(Int32, Int32, out Int32, out Int32)

    Measurement override. Implement your size-to-content logic here.

    Declaration
    protected virtual void MeasureOverride(int availableWidth, int availableHeight, out int desiredWidth, out int desiredHeight)
    Parameters
    Type Name Description
    Int32 availableWidth

    Available size that parent can give to the child. May be MaxValue(when parent wants to measure to content). This is soft constraint. Child can return bigger size to indicate that it wants bigger space and hope that parent can throw in scrolling...

    Int32 availableHeight
    Int32 desiredWidth
    Int32 desiredHeight
    Remarks

    MeasureOverride is designed to be the main customizability point for size control of layout. UIElement authors should override this method, call Measure on each child UIElement, and compute their desired size based upon the measurement of the children. The return value should be the desired size.

    Note: It is required that a parent UIElement calls Measure on each child or they won't be sized/arranged. Typical override follows a pattern roughly like this (pseudo-code):

    protected override void MeasureOverride(int avialableWidth, int availableHeight, out int desiredWidth, out int desiredHeight)
    {
    foreach (UIElement child in VisualChildren)
    {
        child.Measure(availableSize);
        availableSize.Deflate(child.DesiredSize);
        _cache.StoreInfoAboutChild(child);
    }
    
    Size desired = CalculateBasedOnCache(_cache);
    return desired;
    }
    The key aspects of this snippet are:
    • You must call Measure on each child UIElement
    • It is common to cache measurement information between the MeasureOverride and ArrangeOverride method calls
    • Calling base.MeasureOverride is not required.
    • Calls to Measure on children are passing either the same availableSize as the parent, or a subset of the area depending on the type of layout the parent will perform (for example, it would be valid to remove the area for some border or padding).
    | Improve this Doc View Source

    OnButtonDown(ButtonEventArgs)

    Declaration
    protected virtual void OnButtonDown(ButtonEventArgs e)
    Parameters
    Type Name Description
    ButtonEventArgs e
    | Improve this Doc View Source

    OnButtonUp(ButtonEventArgs)

    Declaration
    protected virtual void OnButtonUp(ButtonEventArgs e)
    Parameters
    Type Name Description
    ButtonEventArgs e
    | Improve this Doc View Source

    OnChildDesiredSizeChanged(UIElement)

    Notification that is called by Measure of a child when it ends up with different desired size for the child.

    Declaration
    protected virtual void OnChildDesiredSizeChanged(UIElement child)
    Parameters
    Type Name Description
    UIElement child
    Remarks

    Default implementation simply calls invalidateMeasure(), assuming that layout of a parent should be updated after child changed its size.

    Finer point: this method can only be called in the scenario when the system calls Measure on a child, not when parent calls it since if parent calls it, it means parent has dirty layout and is recalculating already.

    | Improve this Doc View Source

    OnChildrenChanged(UIElement, UIElement, Int32)

    OnChildrenChanged is called when the UIElementCollection of the UIElement is edited.

    Declaration
    protected virtual void OnChildrenChanged(UIElement added, UIElement removed, int indexAffected)
    Parameters
    Type Name Description
    UIElement added
    UIElement removed
    Int32 indexAffected
    | Improve this Doc View Source

    OnGenericEvent(GenericEventArgs)

    Declaration
    protected virtual void OnGenericEvent(GenericEventArgs e)
    Parameters
    Type Name Description
    GenericEventArgs e
    | Improve this Doc View Source

    OnGotFocus(FocusChangedEventArgs)

    Declaration
    protected virtual void OnGotFocus(FocusChangedEventArgs e)
    Parameters
    Type Name Description
    FocusChangedEventArgs e
    | Improve this Doc View Source

    OnLostFocus(FocusChangedEventArgs)

    Declaration
    protected virtual void OnLostFocus(FocusChangedEventArgs e)
    Parameters
    Type Name Description
    FocusChangedEventArgs e
    | Improve this Doc View Source

    OnPreviewButtonDown(ButtonEventArgs)

    Declaration
    protected virtual void OnPreviewButtonDown(ButtonEventArgs e)
    Parameters
    Type Name Description
    ButtonEventArgs e
    | Improve this Doc View Source

    OnPreviewButtonUp(ButtonEventArgs)

    Declaration
    protected virtual void OnPreviewButtonUp(ButtonEventArgs e)
    Parameters
    Type Name Description
    ButtonEventArgs e
    | Improve this Doc View Source

    OnRender(DrawingContext)

    Declaration
    public virtual void OnRender(DrawingContext dc)
    Parameters
    Type Name Description
    DrawingContext dc
    | Improve this Doc View Source

    OnTouchDown(TouchEventArgs)

    Declaration
    protected virtual void OnTouchDown(TouchEventArgs e)
    Parameters
    Type Name Description
    TouchEventArgs e
    | Improve this Doc View Source

    OnTouchGestureChanged(TouchGestureEventArgs)

    Declaration
    protected virtual void OnTouchGestureChanged(TouchGestureEventArgs e)
    Parameters
    Type Name Description
    TouchGestureEventArgs e
    | Improve this Doc View Source

    OnTouchGestureEnded(TouchGestureEventArgs)

    Declaration
    protected virtual void OnTouchGestureEnded(TouchGestureEventArgs e)
    Parameters
    Type Name Description
    TouchGestureEventArgs e
    | Improve this Doc View Source

    OnTouchGestureStarted(TouchGestureEventArgs)

    Declaration
    protected virtual void OnTouchGestureStarted(TouchGestureEventArgs e)
    Parameters
    Type Name Description
    TouchGestureEventArgs e
    | Improve this Doc View Source

    OnTouchMove(TouchEventArgs)

    Declaration
    protected virtual void OnTouchMove(TouchEventArgs e)
    Parameters
    Type Name Description
    TouchEventArgs e
    | Improve this Doc View Source

    OnTouchUp(TouchEventArgs)

    Declaration
    protected virtual void OnTouchUp(TouchEventArgs e)
    Parameters
    Type Name Description
    TouchEventArgs e
    | Improve this Doc View Source

    PointToClient(ref Int32, ref Int32)

    Declaration
    public void PointToClient(ref int x, ref int y)
    Parameters
    Type Name Description
    Int32 x
    Int32 y
    | Improve this Doc View Source

    PointToScreen(ref Int32, ref Int32)

    We are deviating little from their desktop counter parts, mostly for simplicity and perf.

    Declaration
    public void PointToScreen(ref int x, ref int y)
    Parameters
    Type Name Description
    Int32 x
    Int32 y
    | Improve this Doc View Source

    RaiseEvent(RoutedEventArgs)

    Raise the events specified by RoutedEvent

    Declaration
    public void RaiseEvent(RoutedEventArgs args)
    Parameters
    Type Name Description
    RoutedEventArgs args

    RoutedEventArgs for the event to be raised

    Remarks

    This method is a shorthand for This method walks up the visual tree, calling cref="UIElement.BuildRouteCore" on every cref="UIElement"

    NOTE: The RoutedEvent in RoutedEventArgs and EventRoute must be matched

    Once the route is built, it calls InvokeHandlers()

    | Improve this Doc View Source

    RenderRecursive(DrawingContext)

    Declaration
    protected virtual void RenderRecursive(DrawingContext dc)
    Parameters
    Type Name Description
    DrawingContext dc
    | Improve this Doc View Source

    SetMargin(Int32)

    Declaration
    public void SetMargin(int length)
    Parameters
    Type Name Description
    Int32 length
    | Improve this Doc View Source

    SetMargin(Int32, Int32, Int32, Int32)

    Declaration
    public void SetMargin(int left, int top, int right, int bottom)
    Parameters
    Type Name Description
    Int32 left
    Int32 top
    Int32 right
    Int32 bottom
    | Improve this Doc View Source

    UpdateLayout()

    Call this method to ensure that the whoel subtree of elements that includes this UIElement is properly updated.

    Declaration
    public void UpdateLayout()
    Remarks

    This ensures that UIElements with IsMeasureInvalid or IsArrangeInvalid will get call to their MeasureOverride and ArrangeOverride, and all computed sizes will be validated. This method does nothing if layout is clean but it does work if layout is not clean so avoid calling it after each change in the UIElement tree. It makes sense to either never call it (system will do this in a deferred manner) or only call it if you absolutely need updated sizes and positions after you do all changes.

    Events

    | Improve this Doc View Source

    IsEnabledChanged

    Declaration
    public event PropertyChangedEventHandler IsEnabledChanged
    Event Type
    Type Description
    PropertyChangedEventHandler
    | Improve this Doc View Source

    IsVisibleChanged

    Declaration
    public event PropertyChangedEventHandler IsVisibleChanged
    Event Type
    Type Description
    PropertyChangedEventHandler
    | Improve this Doc View Source

    TouchDown

    Declaration
    public event TouchEventHandler TouchDown
    Event Type
    Type Description
    TouchEventHandler
    | Improve this Doc View Source

    TouchGestureChanged

    Declaration
    public event TouchGestureEventHandler TouchGestureChanged
    Event Type
    Type Description
    TouchGestureEventHandler
    | Improve this Doc View Source

    TouchGestureEnd

    Declaration
    public event TouchGestureEventHandler TouchGestureEnd
    Event Type
    Type Description
    TouchGestureEventHandler
    | Improve this Doc View Source

    TouchGestureStart

    Declaration
    public event TouchGestureEventHandler TouchGestureStart
    Event Type
    Type Description
    TouchGestureEventHandler
    | Improve this Doc View Source

    TouchMove

    Declaration
    public event TouchEventHandler TouchMove
    Event Type
    Type Description
    TouchEventHandler
    | Improve this Doc View Source

    TouchUp

    Declaration
    public event TouchEventHandler TouchUp
    Event Type
    Type Description
    TouchEventHandler

    Extension Methods

    LogDispatcher.GetCurrentClassLogger(Object)
    • Improve this Doc
    • View Source
    Back to top Copyright © 2018 nanoFramework Contributors
    Generated by DocFX