Class Layoutable
Implements layout-related functionality for a control.
public class Layoutable : Visual, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed
- Inheritance
-
Layoutable
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
Layoutable()
public Layoutable()
Fields
DesiredSizeProperty
Defines the DesiredSize property.
public static readonly DirectProperty<Layoutable, Size> DesiredSizeProperty
Field Value
HeightProperty
Defines the Height property.
public static readonly StyledProperty<double> HeightProperty
Field Value
HorizontalAlignmentProperty
Defines the HorizontalAlignment property.
public static readonly StyledProperty<HorizontalAlignment> HorizontalAlignmentProperty
Field Value
MarginProperty
Defines the Margin property.
public static readonly StyledProperty<Thickness> MarginProperty
Field Value
MaxHeightProperty
Defines the MaxHeight property.
public static readonly StyledProperty<double> MaxHeightProperty
Field Value
MaxWidthProperty
Defines the MaxWidth property.
public static readonly StyledProperty<double> MaxWidthProperty
Field Value
MinHeightProperty
Defines the MinHeight property.
public static readonly StyledProperty<double> MinHeightProperty
Field Value
MinWidthProperty
Defines the MinWidth property.
public static readonly StyledProperty<double> MinWidthProperty
Field Value
UseLayoutRoundingProperty
Defines the UseLayoutRounding property.
public static readonly StyledProperty<bool> UseLayoutRoundingProperty
Field Value
VerticalAlignmentProperty
Defines the VerticalAlignment property.
public static readonly StyledProperty<VerticalAlignment> VerticalAlignmentProperty
Field Value
WidthProperty
Defines the Width property.
public static readonly StyledProperty<double> WidthProperty
Field Value
Properties
DesiredSize
Gets the size that this element computed during the measure pass of the layout process.
public Size DesiredSize { get; }
Property Value
Height
Gets or sets the height of the element.
public double Height { get; set; }
Property Value
HorizontalAlignment
Gets or sets the element's preferred horizontal alignment in its parent.
public HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
IsArrangeValid
Gets a value indicating whether the control's layouts arrange is valid.
public bool IsArrangeValid { get; }
Property Value
IsMeasureValid
Gets a value indicating whether the control's layout measure is valid.
public bool IsMeasureValid { get; }
Property Value
Margin
Gets or sets the margin around the element.
public Thickness Margin { get; set; }
Property Value
MaxHeight
Gets or sets the maximum height of the element.
public double MaxHeight { get; set; }
Property Value
MaxWidth
Gets or sets the maximum width of the element.
public double MaxWidth { get; set; }
Property Value
MinHeight
Gets or sets the minimum height of the element.
public double MinHeight { get; set; }
Property Value
MinWidth
Gets or sets the minimum width of the element.
public double MinWidth { get; set; }
Property Value
UseLayoutRounding
Gets or sets a value that determines whether the element should be snapped to pixel boundaries at layout time.
public bool UseLayoutRounding { get; set; }
Property Value
VerticalAlignment
Gets or sets the element's preferred vertical alignment in its parent.
public VerticalAlignment VerticalAlignment { get; set; }
Property Value
Width
Gets or sets the width of the element.
public double Width { get; set; }
Property Value
Methods
AffectsArrange<T>(params AvaloniaProperty[])
Marks a property as affecting the control's arrangement.
protected static void AffectsArrange<T>(params AvaloniaProperty[] properties) where T : Layoutable
Parameters
properties
AvaloniaProperty[]The properties.
Type Parameters
T
The control which the property affects.
Remarks
After a call to this method in a control's static constructor, any change to the property will cause InvalidateArrange() to be called on the element.
AffectsMeasure<T>(params AvaloniaProperty[])
Marks a property as affecting the control's measurement.
protected static void AffectsMeasure<T>(params AvaloniaProperty[] properties) where T : Layoutable
Parameters
properties
AvaloniaProperty[]The properties.
Type Parameters
T
The control which the property affects.
Remarks
After a call to this method in a control's static constructor, any change to the property will cause InvalidateMeasure() to be called on the element.
ApplyTemplate()
Creates the visual children of the control, if necessary
public virtual void ApplyTemplate()
Arrange(Rect)
Arranges the control and its children.
public void Arrange(Rect rect)
Parameters
rect
RectThe control's new bounds.
ArrangeCore(Rect)
The default implementation of the control's arrange pass.
protected virtual void ArrangeCore(Rect finalRect)
Parameters
finalRect
RectThe control's new bounds.
Remarks
This method calls ArrangeOverride(Size) which is probably the method you want to override in order to modify a control's arrangement.
ArrangeOverride(Size)
Positions child elements as part of a layout pass.
protected virtual Size ArrangeOverride(Size finalSize)
Parameters
finalSize
SizeThe size available to the control.
Returns
- Size
The actual size used.
InvalidateArrange()
Invalidates the arrangement of the control and queues a new layout pass.
public void InvalidateArrange()
InvalidateMeasure()
Invalidates the measurement of the control and queues a new layout pass.
public void InvalidateMeasure()
Measure(Size)
Carries out a measure of the control.
public void Measure(Size availableSize)
Parameters
availableSize
SizeThe available size for the control.
MeasureCore(Size)
The default implementation of the control's measure pass.
protected virtual Size MeasureCore(Size availableSize)
Parameters
availableSize
SizeThe size available to the control.
Returns
- Size
The desired size for the control.
Remarks
This method calls MeasureOverride(Size) which is probably the method you want to override in order to modify a control's arrangement.
MeasureOverride(Size)
Measures the control and its child elements as part of a layout pass.
protected virtual Size MeasureOverride(Size availableSize)
Parameters
availableSize
SizeThe size available to the control.
Returns
- Size
The desired size for the control.
OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs)
Calls the OnAttachedToVisualTree(VisualTreeAttachmentEventArgs) method for this control and all of its visual descendants.
protected override void OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs e)
Parameters
e
VisualTreeAttachmentEventArgsThe event args.
OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs)
Calls the OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs) method for this control and all of its visual descendants.
protected override void OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs e)
Parameters
e
VisualTreeAttachmentEventArgsThe event args.
OnMeasureInvalidated()
Called by InvalidateMeasure
protected virtual void OnMeasureInvalidated()
OnPropertyChanged(AvaloniaPropertyChangedEventArgs)
Called when a avalonia property changes on the object.
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
Parameters
change
AvaloniaPropertyChangedEventArgsThe property change details.
OnVisualParentChanged(Visual?, Visual?)
Called when the control's visual parent changes.
protected override sealed void OnVisualParentChanged(Visual? oldParent, Visual? newParent)
Parameters
UpdateLayout()
Executes a layout pass.
public void UpdateLayout()
Remarks
You should not usually need to call this method explictly, the layout manager will schedule layout passes itself.
Events
EffectiveViewportChanged
Occurs when the element's effective viewport changes.
public event EventHandler<EffectiveViewportChangedEventArgs>? EffectiveViewportChanged
Event Type
LayoutUpdated
Occurs when a layout pass completes for the control.
public event EventHandler? LayoutUpdated