Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions components/DataTable/src/DataTable/DataColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public partial class DataColumn : ContentControl

private WeakReference<DataTable>? _parent;

internal DataTable? DataTable => _parent?.TryGetTarget(out DataTable? parent) == true ? parent : null;

/// <summary>
/// Gets or sets the width of the largest child contained within the visible <see cref="DataRow"/>s of the <see cref="DataTable"/>.
/// </summary>
Expand All @@ -23,6 +25,12 @@ public partial class DataColumn : ContentControl
/// </summary>
internal GridLength CurrentWidth { get; private set; }

internal bool IsAbsolute => CurrentWidth.IsAbsolute;

internal bool IsAuto => CurrentWidth.IsAuto;

internal bool IsStar => CurrentWidth.IsStar;

/// <summary>
/// Gets or sets whether the column can be resized by the user.
/// </summary>
Expand Down Expand Up @@ -111,10 +119,6 @@ private void ColumnResizedByUserSizer()
CurrentWidth = new(this.ActualWidth);

// Notify the rest of the table to update
if (_parent?.TryGetTarget(out DataTable? parent) == true
&& parent != null)
{
parent.ColumnResized();
}
DataTable?.ColumnResized();
}
}
16 changes: 8 additions & 8 deletions components/DataTable/src/DataTable/DataTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ protected override Size MeasureOverride(Size availableSize)
// We only need to measure elements that are visible
foreach (DataColumn column in elements)
{
if (column.CurrentWidth.IsStar)
if (column.IsStar)
{
proportionalUnits += column.DesiredWidth.Value;
}
else if (column.CurrentWidth.IsAbsolute)
else if (column.IsAbsolute)
{
fixedWidth += column.DesiredWidth.Value;
}
Expand All @@ -75,11 +75,11 @@ protected override Size MeasureOverride(Size availableSize)

foreach (DataColumn column in elements)
{
if (column.CurrentWidth.IsStar)
if (column.IsStar)
{
column.Measure(new Size(proportionalAmount * column.CurrentWidth.Value, availableSize.Height));
}
else if (column.CurrentWidth.IsAbsolute)
else if (column.IsAbsolute)
{
column.Measure(new Size(column.CurrentWidth.Value, availableSize.Height));
}
Expand Down Expand Up @@ -118,11 +118,11 @@ protected override Size ArrangeOverride(Size finalSize)
// We only need to measure elements that are visible
foreach (DataColumn column in elements)
{
if (column.CurrentWidth.IsStar)
if (column.IsStar)
{
proportionalUnits += column.CurrentWidth.Value;
}
else if (column.CurrentWidth.IsAbsolute)
else if (column.IsAbsolute)
{
fixedWidth += column.CurrentWidth.Value;
}
Expand All @@ -141,12 +141,12 @@ protected override Size ArrangeOverride(Size finalSize)

foreach (DataColumn column in elements)
{
if (column.CurrentWidth.IsStar)
if (column.IsStar)
{
width = proportionalAmount * column.CurrentWidth.Value;
column.Arrange(new Rect(x, 0, width, finalSize.Height));
}
else if (column.CurrentWidth.IsAbsolute)
else if (column.IsAbsolute)
{
width = column.CurrentWidth.Value;
column.Arrange(new Rect(x, 0, width, finalSize.Height));
Expand Down