From 189d7720bfaeb0bafdbe24bc95f64813acce4abd Mon Sep 17 00:00:00 2001 From: k-hara Date: Thu, 19 Feb 2026 17:01:55 +0900 Subject: [PATCH] Add internal methods in DataColumn --- components/DataTable/src/DataTable/DataColumn.cs | 14 +++++++++----- components/DataTable/src/DataTable/DataTable.cs | 16 ++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/components/DataTable/src/DataTable/DataColumn.cs b/components/DataTable/src/DataTable/DataColumn.cs index 6f969b15e..3e83f0ecf 100644 --- a/components/DataTable/src/DataTable/DataColumn.cs +++ b/components/DataTable/src/DataTable/DataColumn.cs @@ -13,6 +13,8 @@ public partial class DataColumn : ContentControl private WeakReference? _parent; + internal DataTable? DataTable => _parent?.TryGetTarget(out DataTable? parent) == true ? parent : null; + /// /// Gets or sets the width of the largest child contained within the visible s of the . /// @@ -23,6 +25,12 @@ public partial class DataColumn : ContentControl /// internal GridLength CurrentWidth { get; private set; } + internal bool IsAbsolute => CurrentWidth.IsAbsolute; + + internal bool IsAuto => CurrentWidth.IsAuto; + + internal bool IsStar => CurrentWidth.IsStar; + /// /// Gets or sets whether the column can be resized by the user. /// @@ -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(); } } diff --git a/components/DataTable/src/DataTable/DataTable.cs b/components/DataTable/src/DataTable/DataTable.cs index 7b78b2beb..3956e3ca8 100644 --- a/components/DataTable/src/DataTable/DataTable.cs +++ b/components/DataTable/src/DataTable/DataTable.cs @@ -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; } @@ -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)); } @@ -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; } @@ -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));