IUIElement Interface
Represents a base requirements for an element that has a user interface.
public interface IUIElement : ILogicalTreeNode, IDpiAwareElement, IDisposable
Properties
ActualHeight
Gets the actual height of the element.
int ActualHeight { get; }
Property Value
- int:
The actual height of the element.
Remarks
This is determined by the layout system after Arrange(Rectangle) has completed.
This is only valid if IsArrangeValid is true
.
ActualWidth
Gets the actual width of the element.
int ActualWidth { get; }
Property Value
- int:
The actual width of the element.
Remarks
This is determined by the layout system after Arrange(Rectangle) has completed.
This is only valid if IsArrangeValid is true
.
Bounds
Gets a Rectangle specifying the bounds of the element.
Rectangle Bounds { get; }
Property Value
ClipBounds
Gets a Rectangle specifying the clip bounds when drawing the element.
Rectangle ClipBounds { get; }
Property Value
DesiredSize
Gets the desired size of the element as computed by Measure(Graphics, Size).
Size DesiredSize { get; }
Property Value
- Size:
The desired size of the element as computed by Measure(Graphics, Size).
Remarks
This is only valid if IsMeasureValid is true
.
IsArrangeValid
Gets 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
Gets 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
Gets 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
Gets the actual size of the element.
Size Size { get; }
Property Value
- Size:
The actual size of the element.
Remarks
This is determined by the layout system after Arrange(Rectangle) has completed.
This is only valid if IsArrangeValid is true
.
Visibility
Gets or sets the Visibility of the element.
VisualOffset
Gets the X/Y offset of the element relative to its parent element's coordinate system.
Point VisualOffset { get; }
Property Value
- Point:
The X/Y offset of the element relative to its parent element's coordinate system.
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.
GetDrawState()
Gets the UIElementDrawState for the element.
UIElementDrawState GetDrawState()
Returns
- UIElementDrawState:
The UIElementDrawState for the element.
Remarks
The default implementation of this method returns UIElementDrawState.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 | A PaintEventArgs that contains 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:
A GeneralTransform from this element to a ancestor element.
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:
A GeneralTransform from this element to a descendant element.
Inherited Members
- ILogicalTreeNode.FindAncestor(Type)
- ILogicalTreeNode.GetCommonAncestor(ILogicalTreeNode)
- ILogicalTreeNode.IsAncestorOf(ILogicalTreeNode)
- ILogicalTreeNode.IsDescendantOf(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)