| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- // Copyright (c) The Avalonia Project. All rights reserved.
- // Licensed under the MIT license. See licence.md file in the project root for full license information.
- namespace Avalonia.Controls
- {
- /// <summary>
- /// Holds a row definitions for a <see cref="Grid"/>.
- /// </summary>
- public class RowDefinition : DefinitionBase
- {
- /// <summary>
- /// Defines the <see cref="MaxHeight"/> property.
- /// </summary>
- public static readonly StyledProperty<double> MaxHeightProperty =
- AvaloniaProperty.Register<RowDefinition, double>(nameof(MaxHeight), double.PositiveInfinity);
- /// <summary>
- /// Defines the <see cref="MinHeight"/> property.
- /// </summary>
- public static readonly StyledProperty<double> MinHeightProperty =
- AvaloniaProperty.Register<RowDefinition, double>(nameof(MinHeight));
- /// <summary>
- /// Defines the <see cref="Height"/> property.
- /// </summary>
- public static readonly StyledProperty<GridLength> HeightProperty =
- AvaloniaProperty.Register<RowDefinition, GridLength>(nameof(Height), new GridLength(1, GridUnitType.Star));
- /// <summary>
- /// Initializes static members of the <see cref="RowDefinition"/> class.
- /// </summary>
- static RowDefinition()
- {
- AffectsParentMeasure(MaxHeightProperty, MinHeightProperty);
- HeightProperty.Changed.AddClassHandler<DefinitionBase>(OnUserSizePropertyChanged);
- }
- /// <summary>
- /// Initializes a new instance of the <see cref="RowDefinition"/> class.
- /// </summary>
- public RowDefinition()
- {
- }
- /// <summary>
- /// Initializes a new instance of the <see cref="RowDefinition"/> class.
- /// </summary>
- /// <param name="value">The height of the row.</param>
- /// <param name="type">The height unit of the column.</param>
- public RowDefinition(double value, GridUnitType type)
- {
- Height = new GridLength(value, type);
- }
- /// <summary>
- /// Initializes a new instance of the <see cref="RowDefinition"/> class.
- /// </summary>
- /// <param name="height">The height of the column.</param>
- public RowDefinition(GridLength height)
- {
- Height = height;
- }
- /// <summary>
- /// Gets the actual calculated height of the row.
- /// </summary>
- public double ActualHeight => Parent?.GetFinalRowDefinitionHeight(Index) ?? 0d;
- /// <summary>
- /// Gets or sets the maximum height of the row in DIPs.
- /// </summary>
- public double MaxHeight
- {
- get
- {
- return GetValue(MaxHeightProperty);
- }
- set
- {
- SetValue(MaxHeightProperty, value);
- }
- }
- /// <summary>
- /// Gets or sets the minimum height of the row in DIPs.
- /// </summary>
- public double MinHeight
- {
- get
- {
- return GetValue(MinHeightProperty);
- }
- set
- {
- SetValue(MinHeightProperty, value);
- }
- }
- /// <summary>
- /// Gets or sets the height of the row.
- /// </summary>
- public GridLength Height
- {
- get
- {
- return GetValue(HeightProperty);
- }
- set
- {
- SetValue(HeightProperty, value);
- }
- }
- internal override GridLength UserSizeValueCache => this.Height;
- internal override double UserMinSizeValueCache => this.MinHeight;
- internal override double UserMaxSizeValueCache => this.MaxHeight;
- }
- }
|