private void ReorganizeChildren(TableViewModel model) { ResizeGrid(model.TableHeight(), model.TableWidth()); TableGrid.Children.Clear(); TableGrid.Children.Add(model.LeftTopControl); foreach (var time in model.TimeIntervals) { TableGrid.Children.Add(time); } foreach (var day in model.DayLine) { TableGrid.Children.Add(day); } foreach (var title in model.Titles) { TableGrid.Children.Add(title); } for (int row = 0; row < model.ClassesRowsCount; row++) { for (int col = 0; col < model.ClassesColumnsCount; col++) { var card = model.ClassesCards[row][col]; if (card != null) TableGrid.Children.Add(card); } } }