In This Article

IUIElement Interface

Represents a base requirements for an element that has a user interface.

public interface IUIElement : ILogicalTreeNode, IDpiAwareElement, IDisposable

Properties

ActualHeight

The actual height of the element.

int ActualHeight { get; }

Property Value

int

Remarks

This is determined by the layout system after Arrange(Rectangle) has completed. This is only valid if IsArrangeValid is true.

ActualWidth

The actual width of the element.

int ActualWidth { get; }

Property Value

int

Remarks

This is determined by the layout system after Arrange(Rectangle) has completed. This is only valid if IsArrangeValid is true.

Bounds

A Rectangle specifying the bounds of the element.

Rectangle Bounds { get; }

Property Value

Rectangle

ClipBounds

A Rectangle specifying the clip bounds when drawing the element.

Rectangle ClipBounds { get; }

Property Value

Rectangle

DesiredSize

The desired size of the element as computed by Measure(Graphics?, Size).

Size DesiredSize { get; }

Property Value

Size

Remarks

This is only valid if IsMeasureValid is true.

IsArrangeValid

Indicates whether the value of the DesiredSize property and position of child elements is valid.

bool IsArrangeValid { get; }

Property Value

bool:

true if the value of the DesiredSize property and position of child elements is valid; otherwise, false.

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.

IsMeasureValid

Indicates whether the value of the DesiredSize property is valid.

bool IsMeasureValid { get; }

Property Value

bool:

true if the value of the DesiredSize property is valid; otherwise, false.

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.

IsRightToLeft

Indicates whether the element is using a right-to-left layout.

bool IsRightToLeft { get; }

Property Value

bool:

true if the element is using a right-to-left layout; otherwise, false.

Size

The actual size of the element.

Size Size { get; }

Property Value

Size

Remarks

This is determined by the layout system after Arrange(Rectangle) has completed. This is only valid if IsArrangeValid is true.

Visibility

The Visibility of the element.

Visibility Visibility { get; set; }

Property Value

Visibility

VisualOffset

The X/Y offset of the element relative to its parent element's coordinate system.

Point VisualOffset { get; }

Property Value

Point

Remarks

This is determined by the layout system after Arrange(Rectangle) has completed. This is only valid if IsArrangeValid is true.

Methods

Arrange(Rectangle)

Positions child elements and determines a size for the IUIElement.

void Arrange(Rectangle newBounds)
Parameter Type Description
newBounds Rectangle

The final bounds of the element.

ContainsLocation(Point)

Used with hit-testing, returning whether this element's bounds contains the specified location.

bool ContainsLocation(Point location)
Parameter Type Description
location Point

The Point location to examine.

Returns

bool:

true if this element's bounds contains the specified location; otherwise, false.

Remarks

Override this method to prevent certain portions of the element's bounds from being included in hit-testing.

CreateGraphics()

Creates the Graphics object for the use with the object.

Graphics? CreateGraphics()

Returns

Graphics

GetDrawState()

The UIElementDrawState for the element.

UIElementDrawState GetDrawState()

Returns

UIElementDrawState

Remarks

The default implementation of this method returns None.

HitTest(PointHitTestParameters)

Hit tests to find the IUIElement that contains the specified coordinates.

PointHitTestResult HitTest(PointHitTestParameters hitTestParams)
Parameter Type Description
hitTestParams PointHitTestParameters

A PointHitTestParameters containing hit test parameters.

Returns

PointHitTestResult:

A PointHitTestResult containing the hit test result.

HitTest(PointHitTestParameters, Func<IUIElement, PointHitTestParameters, bool>)

Hit tests to find the IUIElement that contains the specified coordinates.

PointHitTestResult HitTest(PointHitTestParameters hitTestParams, Func<IUIElement, PointHitTestParameters, bool> filter)
Parameter Type Description
hitTestParams PointHitTestParameters

A PointHitTestParameters containing hit test parameters.

filter Func<IUIElement, PointHitTestParameters, bool>

Optionally defines a filter which must return true for an element to match the hit test.

Returns

PointHitTestResult:

A PointHitTestResult containing the hit test result.

HitTestRecursive(PointHitTestParameters)

Recursively hit tests to find the IUIElement that contains the specified coordinates.

PointHitTestResult HitTestRecursive(PointHitTestParameters hitTestParams)
Parameter Type Description
hitTestParams PointHitTestParameters

A PointHitTestParameters containing hit test parameters.

Returns

PointHitTestResult:

A PointHitTestResult containing the hit test result.

HitTestRecursive(PointHitTestParameters, Func<IUIElement, PointHitTestParameters, bool>)

Recursively hit tests to find the IUIElement that contains the specified coordinates.

PointHitTestResult HitTestRecursive(PointHitTestParameters hitTestParams, Func<IUIElement, PointHitTestParameters, bool> filter)
Parameter Type Description
hitTestParams PointHitTestParameters

A PointHitTestParameters containing hit test parameters.

filter Func<IUIElement, PointHitTestParameters, bool>

Optionally defines a filter which must return true for an element to match the hit test.

Returns

PointHitTestResult:

A PointHitTestResult containing the hit test result.

Invalidate(InvalidationLevels, InvalidationTypes)

Invalidates the specified states for the element or its related elements.

void Invalidate(InvalidationLevels levels, InvalidationTypes types)
Parameter Type Description
levels InvalidationLevels

The hierarchy levels at which to invalidate.

types InvalidationTypes

The types of invalidation to perform.

InvalidateArrange()

Invalidates the layout of the element.

void InvalidateArrange()

InvalidateMeasure()

Invalidates the measurement of the element.

void InvalidateMeasure()

Measure(Graphics?, Size)

Measures the element and updates the DesiredSize property.

void Measure(Graphics? g, Size availableSize)
Parameter Type Description
g Graphics

The Graphics object to use for measurement.

availableSize Size

The available size that parent can give to the child. The child can return bigger in hopes that the parent will become scrollable. The value may also be infinity to indicate that the desired measurements of the element are wanted.

Remarks

The Measure(Graphics?, Size) method should be called by parents on their children. Internally, Measure(Graphics?, Size) calls the MeasureCore override on the same object, giving it opportunity to compute its DesiredSize. This method will return immediately if the child's measurements are valid, previously measured and availableSize is the same as cached. This method also resets the IsMeasureValid bit on the child.

NotifyChildDesiredSizeChanged()

Notifies that a child object's desired size has changed.

void NotifyChildDesiredSizeChanged()

NotifyMouseLeaveEvent()

Notifies the object of a a mouse leave event.

void NotifyMouseLeaveEvent()

Remarks

This enables the object to cancel hot state tracking.

Render(PaintEventArgs)

Renders the element.

void Render(PaintEventArgs e)
Parameter Type Description
e PaintEventArgs

The event data.

TransformToAncestor(IUIElement)

Returns a GeneralTransform from this element to an ancestor element.

GeneralTransform TransformToAncestor(IUIElement ancestor)
Parameter Type Description
ancestor IUIElement

The ancestor IUIElement.

Returns

GeneralTransform

TransformToDescendant(IUIElement)

Returns a GeneralTransform from this element to a descendant element.

GeneralTransform TransformToDescendant(IUIElement descendant)
Parameter Type Description
descendant IUIElement

The descendant IUIElement.

Returns

GeneralTransform

Inherited Members

Extension Methods