namespace Avalonia.Controls
{
///
/// Holds a column definitions for a .
///
public class ColumnDefinition : DefinitionBase
{
///
/// Defines the property.
///
public static readonly StyledProperty MaxWidthProperty =
AvaloniaProperty.Register(nameof(MaxWidth), double.PositiveInfinity);
///
/// Defines the property.
///
public static readonly StyledProperty MinWidthProperty =
AvaloniaProperty.Register(nameof(MinWidth));
///
/// Defines the property.
///
public static readonly StyledProperty WidthProperty =
AvaloniaProperty.Register(nameof(Width), new GridLength(1, GridUnitType.Star));
///
/// Initializes static members of the class.
///
static ColumnDefinition()
{
AffectsParentMeasure(MinWidthProperty, MaxWidthProperty);
WidthProperty.Changed.AddClassHandler(OnUserSizePropertyChanged);
}
///
/// Initializes a new instance of the class.
///
public ColumnDefinition()
{
}
///
/// Initializes a new instance of the class.
///
/// The width of the column.
/// The width unit of the column.
public ColumnDefinition(double value, GridUnitType type)
{
Width = new GridLength(value, type);
}
///
/// Initializes a new instance of the class.
///
/// The width of the column.
public ColumnDefinition(GridLength width)
{
Width = width;
}
///
/// Gets the actual calculated width of the column.
///
public double ActualWidth => Parent?.GetFinalColumnDefinitionWidth(Index) ?? 0d;
///
/// Gets or sets the maximum width of the column in DIPs.
///
public double MaxWidth
{
get
{
return GetValue(MaxWidthProperty);
}
set
{
SetValue(MaxWidthProperty, value);
}
}
///
/// Gets or sets the minimum width of the column in DIPs.
///
public double MinWidth
{
get
{
return GetValue(MinWidthProperty);
}
set
{
SetValue(MinWidthProperty, value);
}
}
///
/// Gets or sets the width of the column.
///
public GridLength Width
{
get
{
return GetValue(WidthProperty);
}
set
{
SetValue(WidthProperty, value);
}
}
internal override GridLength UserSizeValueCache => this.Width;
internal override double UserMinSizeValueCache => this.MinWidth;
internal override double UserMaxSizeValueCache => this.MaxWidth;
}
}