Skip to content

Commit 189d772

Browse files
committed
Add internal methods in DataColumn
1 parent c9173e8 commit 189d772

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

components/DataTable/src/DataTable/DataColumn.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public partial class DataColumn : ContentControl
1313

1414
private WeakReference<DataTable>? _parent;
1515

16+
internal DataTable? DataTable => _parent?.TryGetTarget(out DataTable? parent) == true ? parent : null;
17+
1618
/// <summary>
1719
/// Gets or sets the width of the largest child contained within the visible <see cref="DataRow"/>s of the <see cref="DataTable"/>.
1820
/// </summary>
@@ -23,6 +25,12 @@ public partial class DataColumn : ContentControl
2325
/// </summary>
2426
internal GridLength CurrentWidth { get; private set; }
2527

28+
internal bool IsAbsolute => CurrentWidth.IsAbsolute;
29+
30+
internal bool IsAuto => CurrentWidth.IsAuto;
31+
32+
internal bool IsStar => CurrentWidth.IsStar;
33+
2634
/// <summary>
2735
/// Gets or sets whether the column can be resized by the user.
2836
/// </summary>
@@ -111,10 +119,6 @@ private void ColumnResizedByUserSizer()
111119
CurrentWidth = new(this.ActualWidth);
112120

113121
// Notify the rest of the table to update
114-
if (_parent?.TryGetTarget(out DataTable? parent) == true
115-
&& parent != null)
116-
{
117-
parent.ColumnResized();
118-
}
122+
DataTable?.ColumnResized();
119123
}
120124
}

components/DataTable/src/DataTable/DataTable.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ protected override Size MeasureOverride(Size availableSize)
5757
// We only need to measure elements that are visible
5858
foreach (DataColumn column in elements)
5959
{
60-
if (column.CurrentWidth.IsStar)
60+
if (column.IsStar)
6161
{
6262
proportionalUnits += column.DesiredWidth.Value;
6363
}
64-
else if (column.CurrentWidth.IsAbsolute)
64+
else if (column.IsAbsolute)
6565
{
6666
fixedWidth += column.DesiredWidth.Value;
6767
}
@@ -75,11 +75,11 @@ protected override Size MeasureOverride(Size availableSize)
7575

7676
foreach (DataColumn column in elements)
7777
{
78-
if (column.CurrentWidth.IsStar)
78+
if (column.IsStar)
7979
{
8080
column.Measure(new Size(proportionalAmount * column.CurrentWidth.Value, availableSize.Height));
8181
}
82-
else if (column.CurrentWidth.IsAbsolute)
82+
else if (column.IsAbsolute)
8383
{
8484
column.Measure(new Size(column.CurrentWidth.Value, availableSize.Height));
8585
}
@@ -118,11 +118,11 @@ protected override Size ArrangeOverride(Size finalSize)
118118
// We only need to measure elements that are visible
119119
foreach (DataColumn column in elements)
120120
{
121-
if (column.CurrentWidth.IsStar)
121+
if (column.IsStar)
122122
{
123123
proportionalUnits += column.CurrentWidth.Value;
124124
}
125-
else if (column.CurrentWidth.IsAbsolute)
125+
else if (column.IsAbsolute)
126126
{
127127
fixedWidth += column.CurrentWidth.Value;
128128
}
@@ -141,12 +141,12 @@ protected override Size ArrangeOverride(Size finalSize)
141141

142142
foreach (DataColumn column in elements)
143143
{
144-
if (column.CurrentWidth.IsStar)
144+
if (column.IsStar)
145145
{
146146
width = proportionalAmount * column.CurrentWidth.Value;
147147
column.Arrange(new Rect(x, 0, width, finalSize.Height));
148148
}
149-
else if (column.CurrentWidth.IsAbsolute)
149+
else if (column.IsAbsolute)
150150
{
151151
width = column.CurrentWidth.Value;
152152
column.Arrange(new Rect(x, 0, width, finalSize.Height));

0 commit comments

Comments
 (0)