private void PopulateList() { _thisGrid !.Children.Clear(); int x = default; int c; int r; c = 0; r = 0; foreach (var thisPiece in _numberList !) { NumberPieceWPF thisGraphics = new NumberPieceWPF(); PieceBindings(thisGraphics, thisPiece); if (Columns == 0 && Rows == 1) { AddControlToGrid(_thisGrid, thisGraphics, 0, x); } else if (Columns == 1 && Rows == 1) { AddControlToGrid(_thisGrid, thisGraphics, x, 0); } else if (Columns > 1) { AddControlToGrid(_thisGrid, thisGraphics, r, c); c += 1; if (c >= Columns) { c = 0; r += 1; } } else { // rows AddControlToGrid(_thisGrid, thisGraphics, r, c); r += 1; if (r >= Rows) { r = 0; c += 1; } } if (r > 14 || c > 14) { throw new BasicBlankException("Rethinking is now required."); } x += 1; } }
private void PieceBindings(NumberPieceWPF thisGraphics, NumberPieceCP thisPiece) { thisGraphics.Height = _graphicsSize !.GetWidthHeight; thisGraphics.Width = _graphicsSize.GetWidthHeight; thisGraphics.Visibility = Visibility.Visible; // i think needs to manually be set. var thisBind = GetCommandBinding(nameof(NumberPicker.NumberPickedCommand)); //okay this is old fashioned this time. thisGraphics.SetBinding(GraphicsCommand.CommandProperty, thisBind); thisGraphics.CommandParameter = thisPiece; // must be piece, not simply the color. something else will figure out the color. thisGraphics.Margin = new Thickness(5, 5, 5, 5); thisGraphics.DataContext = thisPiece; thisGraphics.SetBinding(NumberPieceWPF.IsSelectedProperty, new Binding(nameof(BaseGraphicsCP.IsSelected))); // i think thisGraphics.SetBinding(IsEnabledProperty, new Binding(nameof(BaseGraphicsCP.IsEnabled))); thisGraphics.SetBinding(NumberPieceWPF.NumberValueProperty, new Binding(nameof(NumberPieceCP.NumberValue))); thisGraphics.SendPiece(thisPiece); }