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
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
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.
ClipBounds
A Rectangle specifying the clip bounds when drawing the element.
DesiredSize
The desired size of the element as computed by Measure(Graphics?, Size).
IsArrangeValid
Indicates whether the value of the DesiredSize property and position of child elements is valid.
bool IsArrangeValid { get; }
Property Value
- bool:
trueif 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:
trueif 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:
trueif the element is using a right-to-left layout; otherwise,false.
Size
The actual size of the element.
Size Size { get; }
Property Value
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.
VisualOffset
The X/Y offset of the element relative to its parent element's coordinate system.
Point VisualOffset { get; }
Property Value
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:
trueif 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.
GetDrawState()
The UIElementDrawState for the element.
UIElementDrawState GetDrawState()
Returns
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 |
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 |
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
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
Inherited Members
- ILogicalTreeNode.IsAncestorOf(ILogicalTreeNode)
- ILogicalTreeNode.Children
- ILogicalTreeNode.Parent
- IDpiAwareElement.DpiScaleChanged(SizeF)
- IDpiAwareElement.DpiScaleFactor
- IDisposable.Dispose()
Extension Methods
- DpiAwareElementExtensions.AutoScaleFont(IDpiAwareElement, Font)
- DpiAwareElementExtensions.AutoScaleFontSize(IDpiAwareElement, float)
- DpiAwareElementExtensions.ScaleLogicalValue(IDpiAwareElement, Padding)
- DpiAwareElementExtensions.ScaleLogicalValue(IDpiAwareElement, Point)
- DpiAwareElementExtensions.ScaleLogicalValue(IDpiAwareElement, Rectangle)
- DpiAwareElementExtensions.ScaleLogicalValue(IDpiAwareElement, Size)
- DpiAwareElementExtensions.ScaleLogicalValue(IDpiAwareElement, SizeF)
- DpiAwareElementExtensions.ScaleLogicalValue(IDpiAwareElement, int)
- DpiAwareElementExtensions.ScaleLogicalValue(IDpiAwareElement, float)
- DpiAwareElementExtensions.ScaleLogicalValue(IDpiAwareElement, Padding)
- DpiAwareElementExtensions.SynchronizeScaleFactorWithChildren(IDpiAwareElement)
- ILogicalTreeNodeExtensions.FindCommonLogicalAncestor(ILogicalTreeNode, ILogicalTreeNode)
- ILogicalTreeNodeExtensions.FindLogicalAncestorOfType<T>(ILogicalTreeNode, bool)
- ILogicalTreeNodeExtensions.FindLogicalDescendantOfType<T>(ILogicalTreeNode, bool)
- ILogicalTreeNodeExtensions.GetLogicalAncestors(ILogicalTreeNode)
- ILogicalTreeNodeExtensions.GetLogicalChildren(ILogicalTreeNode)
- ILogicalTreeNodeExtensions.GetLogicalDescendants(ILogicalTreeNode)
- ILogicalTreeNodeExtensions.GetLogicalParent(ILogicalTreeNode)
- ILogicalTreeNodeExtensions.GetLogicalParent<T>(ILogicalTreeNode)
- ILogicalTreeNodeExtensions.GetLogicalSiblings(ILogicalTreeNode)
- ILogicalTreeNodeExtensions.GetSelfAndLogicalAncestors(ILogicalTreeNode)
- ILogicalTreeNodeExtensions.GetSelfAndLogicalDescendants(ILogicalTreeNode)
- ILogicalTreeNodeExtensions.IsLogicalAncestorOf(ILogicalTreeNode, ILogicalTreeNode)
- ObjectExtensions.TryConvertToDouble(object, out double)
- ObjectExtensions.TryConvertToDouble(object, IFormatProvider, out double)