Skip to content
Open
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
56 changes: 46 additions & 10 deletions components/DataTable/src/DataTable/DataRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,31 @@ protected override Size MeasureOverride(Size availableSize)

double maxHeight = 0;

if (Children.Count > 0)
// If we don't have a grid, just layout children like a horizontal StackPanel.
if (_parentPanel is null)
{
// If we don't have a grid, just measure first child to get row height and take available space
if (_parentPanel is null)
double totalWidth = 0;

for (int i = 0; i < Children.Count; i++)
{
Children[0].Measure(availableSize);
return new Size(availableSize.Width, Children[0].DesiredSize.Height);
var child = Children[i];
if (child?.Visibility != Visibility.Visible)
continue;

child.Measure(availableSize);

totalWidth += child.DesiredSize.Width;
maxHeight = Math.Max(maxHeight, child.DesiredSize.Height);
}

return new Size(totalWidth, maxHeight);
}

if (Children.Count > 0)
{
// Handle DataTable Parent
else if (_parentTable != null
&& _parentTable.Children.Count == Children.Count)
if (_parentTable != null &&
_parentTable.Children.Count == Children.Count)
{
// TODO: Need to check visibility
// Measure all children since we need to determine the row's height at minimum
Expand Down Expand Up @@ -170,19 +184,41 @@ protected override Size MeasureOverride(Size availableSize)

protected override Size ArrangeOverride(Size finalSize)
{
// If we don't have a grid, just layout children like a horizontal StackPanel.
if (_parentPanel is null)
{
double x = 0;

for (int i = 0; i < Children.Count; i++)
{
var child = Children[i];
if (child?.Visibility != Visibility.Visible)
continue;

double width = child.DesiredSize.Width;

child.Arrange(new Rect(x, 0, width, finalSize.Height));

x += width;
}

return new Size(x, finalSize.Height);
}

int column = 0;
double x = 0;

// Try and grab Column Spacing from DataTable, if not a parent Grid, if not 0.
double spacing = _parentTable?.ColumnSpacing ?? (_parentPanel as Grid)?.ColumnSpacing ?? 0;

double width = 0;

if (_parentPanel != null)
{
double x = 0;

int i = 0;
foreach (UIElement child in Children.Where(static e => e.Visibility == Visibility.Visible))
{
double width;

if (_parentPanel is Grid grid &&
column < grid.ColumnDefinitions.Count)
{
Expand Down