private static void RefreshChildIndexes(AutoIndexGrid grid) { var columns = grid.ColumnDefinitions.Count; var currentColumn = 0; var currentRow = 0; var rowDefinitions = new List <RowDefinition>(); var currentRowDefinition = new RowDefinition { Height = GridLength.Auto }; for (int i = 0; i < grid.Children.Count; i++) { var gridChild = grid.Children[i]; if (GetRowBreak(gridChild) && currentColumn != 0) { rowDefinitions.Add(currentRowDefinition); currentRowDefinition = new RowDefinition { Height = GridLength.Auto }; currentColumn = 0; ++currentRow; } var rowHeight = GetRowHeight(gridChild); if (rowHeight != GridLength.Auto) { currentRowDefinition = new RowDefinition() { Height = rowHeight } } ; SetRow(gridChild, currentRow); SetColumn(gridChild, currentColumn); if (++currentColumn == columns || i == grid.Children.Count - 1) { rowDefinitions.Add(currentRowDefinition); currentRowDefinition = new RowDefinition { Height = GridLength.Auto }; ++currentRow; currentColumn = 0; } } grid.RowDefinitions.Clear(); foreach (var rowDefinition in rowDefinitions) { grid.RowDefinitions.Add(rowDefinition); } }
private static void RefreshColumns(AutoIndexGrid grid) { if (string.IsNullOrWhiteSpace(grid.Columns)) { return; } grid.ColumnDefinitions.Clear(); var columnDefinitions = grid.Columns.Split(new [] { ' ', ',' }); foreach (var columnDefinition in GetColumnDefinitions(columnDefinitions)) { grid.ColumnDefinitions.Add(columnDefinition); } }