Skip to content

Commit

Permalink
Initial test to resize item columns based on header column
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-hawker committed Jun 14, 2023
1 parent b3dfe8f commit 8de8ef2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions components/DataTable/src/DataTable/DataColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,37 @@ public DataColumn()

protected override void OnApplyTemplate()
{
if (PART_ColumnSizer != null)
{
PART_ColumnSizer.TargetControl = null;
PART_ColumnSizer.ManipulationCompleted -= this.PART_ColumnSizer_ManipulationCompleted;
}

PART_ColumnSizer = GetTemplateChild(nameof(PART_ColumnSizer)) as ContentSizer;

if (PART_ColumnSizer != null)
{
PART_ColumnSizer.TargetControl = this;
PART_ColumnSizer.ManipulationCompleted += this.PART_ColumnSizer_ManipulationCompleted;
}

base.OnApplyTemplate();
}

private void PART_ColumnSizer_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
var parent = this.FindAscendant<ItemsPresenter>();

// TODO: Would be nice for Visual Tree helpers to have limit on depth search,
// as could grab the direct Panel descendant and then search that for DataRow
// vs. exploring the whole Header content as well (which has a Panel in our case as well...)

if (parent != null)
{
foreach (DataRow row in parent.FindDescendants().Where(element => element is DataRow))
{
row.InvalidateArrange();
}
}
}
}

0 comments on commit 8de8ef2

Please sign in to comment.