From 479420d05755cb3bd6fe4dc098d1c864e83635ec 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 b5a6ea143..6fbb7e028 100644 --- a/components/DataTable/src/DataTable/DataColumn.cs +++ b/components/DataTable/src/DataTable/DataColumn.cs @@ -16,6 +16,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 . /// @@ -26,6 +28,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. /// @@ -118,10 +126,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 cb362c761..5842c30b9 100644 --- a/components/DataTable/src/DataTable/DataTable.cs +++ b/components/DataTable/src/DataTable/DataTable.cs @@ -58,11 +58,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; } @@ -76,11 +76,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)); } @@ -120,11 +120,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; } @@ -143,12 +143,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));