void MergeCells(Label prevLabel, int colIndex) { int colIndexPrevLabel = (int)prevLabel.GetValue(Grid.ColumnProperty); int mergeCount = colIndex - colIndexPrevLabel + 1; prevLabel.SetValue(Grid.ColumnSpanProperty, mergeCount); prevLabel.Width = CELL_WIDTH * mergeCount; }