csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
3.6 KiB
116 lines
3.6 KiB
namespace Avalonia.Controls
|
|
{
|
|
/// <summary>
|
|
/// Holds a column definitions for a <see cref="Grid"/>.
|
|
/// </summary>
|
|
public class ColumnDefinition : DefinitionBase
|
|
{
|
|
/// <summary>
|
|
/// Defines the <see cref="MaxWidth"/> property.
|
|
/// </summary>
|
|
public static readonly StyledProperty<double> MaxWidthProperty =
|
|
AvaloniaProperty.Register<ColumnDefinition, double>(nameof(MaxWidth), double.PositiveInfinity);
|
|
|
|
/// <summary>
|
|
/// Defines the <see cref="MinWidth"/> property.
|
|
/// </summary>
|
|
public static readonly StyledProperty<double> MinWidthProperty =
|
|
AvaloniaProperty.Register<ColumnDefinition, double>(nameof(MinWidth));
|
|
|
|
/// <summary>
|
|
/// Defines the <see cref="Width"/> property.
|
|
/// </summary>
|
|
public static readonly StyledProperty<GridLength> WidthProperty =
|
|
AvaloniaProperty.Register<ColumnDefinition, GridLength>(nameof(Width), new GridLength(1, GridUnitType.Star));
|
|
|
|
/// <summary>
|
|
/// Initializes static members of the <see cref="ColumnDefinition"/> class.
|
|
/// </summary>
|
|
static ColumnDefinition()
|
|
{
|
|
AffectsParentMeasure(MinWidthProperty, MaxWidthProperty);
|
|
|
|
WidthProperty.Changed.AddClassHandler<DefinitionBase>(OnUserSizePropertyChanged);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ColumnDefinition"/> class.
|
|
/// </summary>
|
|
public ColumnDefinition()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ColumnDefinition"/> class.
|
|
/// </summary>
|
|
/// <param name="value">The width of the column.</param>
|
|
/// <param name="type">The width unit of the column.</param>
|
|
public ColumnDefinition(double value, GridUnitType type)
|
|
{
|
|
Width = new GridLength(value, type);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ColumnDefinition"/> class.
|
|
/// </summary>
|
|
/// <param name="width">The width of the column.</param>
|
|
public ColumnDefinition(GridLength width)
|
|
{
|
|
Width = width;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the actual calculated width of the column.
|
|
/// </summary>
|
|
public double ActualWidth => Parent?.GetFinalColumnDefinitionWidth(Index) ?? 0d;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the maximum width of the column in DIPs.
|
|
/// </summary>
|
|
public double MaxWidth
|
|
{
|
|
get
|
|
{
|
|
return GetValue(MaxWidthProperty);
|
|
}
|
|
set
|
|
{
|
|
SetValue(MaxWidthProperty, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the minimum width of the column in DIPs.
|
|
/// </summary>
|
|
public double MinWidth
|
|
{
|
|
get
|
|
{
|
|
return GetValue(MinWidthProperty);
|
|
}
|
|
set
|
|
{
|
|
SetValue(MinWidthProperty, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the width of the column.
|
|
/// </summary>
|
|
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;
|
|
}
|
|
}
|
|
|