public MatrixViewModel(IReadOnlyList<BoxModel> boxes, int columnCount, int rowCount, HorizontalAlignment defaultColumnAlignment = HorizontalAlignment.Center, VerticalAlignment defaultRowAlignment = VerticalAlignment.Center, VerticalAlignment defaultMatrixAlignment = VerticalAlignment.Center) : base(boxes, GetPositions(columnCount, rowCount)) { Contract.Requires(columnCount >= 1); Contract.Requires(rowCount >= 1); Contract.Requires(boxes.Count == columnCount * rowCount); Contract.Requires(defaultColumnAlignment.IsValid()); Contract.Requires(defaultRowAlignment.IsValid()); columnAlignments = new List<HorizontalAlignment>(); ColumnAlignments = new ReadOnlyCollection<HorizontalAlignment>(columnAlignments); rowAlignments = new List<VerticalAlignment>(); RowAlignments = new ReadOnlyCollection<VerticalAlignment>(rowAlignments); VerticalInlineAlignment = defaultMatrixAlignment; AlignmentProtocols = new AlignmentProtocolCollection(this); for (int x = 0; x < columnCount; x++) this.columnAlignments.Add(defaultColumnAlignment); for (int y = 0; y < rowCount; y++) this.rowAlignments.Add(defaultRowAlignment); }