Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using System.Linq;
using Windows.System;
using Windows.UI.Core;
using Windows.UI.Xaml;
Expand Down Expand Up @@ -239,9 +241,17 @@ private bool HorizontalMove(double horizontalChange)
return true;
}

var columnsWithAutomaticWidth = Resizable.ColumnDefinitions.Where(x => (x.Width.IsStar || x.Width.IsAuto) && x != CurrentColumn);

// if current column has fixed width then resize it
if (!IsStarColumn(CurrentColumn))
{
// Check if all automatic width columns will respect min and max width after resize
if (!AreValidColumnWidths(columnsWithAutomaticWidth, horizontalChange * -1))
{
return false;
}

// No need to check for the Column Min width because it is automatically respected
if (!SetColumnWidth(CurrentColumn, horizontalChange, GridUnitType.Pixel))
{
Expand All @@ -258,6 +268,15 @@ private bool HorizontalMove(double horizontalChange)
return false;
}

// Remove the Sibling as it will be checked during resize
columnsWithAutomaticWidth = columnsWithAutomaticWidth.Where(x => x != SiblingColumn);

// Check if all automatic width columns will respect min and max width after resize
if (!AreValidColumnWidths(columnsWithAutomaticWidth, horizontalChange))
{
return false;
}

if (!SetColumnWidth(SiblingColumn, horizontalChange * -1, GridUnitType.Pixel))
{
return true;
Expand Down Expand Up @@ -297,5 +316,18 @@ private bool HorizontalMove(double horizontalChange)

return false;
}

private bool AreValidColumnWidths(IEnumerable<ColumnDefinition> columns, double horizontalChange)
{
foreach (var column in columns)
{
if (!IsValidColumnWidth(column, horizontalChange))
{
return false;
}
}

return true;
}
}
}