private void PopulateList() { _thisGrid !.Children.Clear(); int x = default; int c; int r; c = 0; r = 0; foreach (var thisPiece in _numberList !) { NumberPieceXF thisGraphics = new NumberPieceXF(); 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(NumberPieceXF thisGraphics, NumberPieceCP thisPiece) { thisGraphics.HeightRequest = _graphicsSize !.GetWidthHeight; thisGraphics.WidthRequest = _graphicsSize.GetWidthHeight; thisGraphics.IsVisible = true; // i think needs to manually be set. var thisBind = GetCommandBinding(nameof(NumberPicker.NumberPickedCommand)); thisGraphics.SetBinding(GameGraphics.Base.GraphicsCommand.CommandProperty, thisBind); thisGraphics.CommandParameter = thisPiece; // must be piece, not simply the color. something else will figure out the color. thisGraphics.BindingContext = thisPiece; thisGraphics.SetBinding(NumberPieceXF.IsSelectedProperty, new Binding(nameof(BaseGraphicsCP.IsSelected))); // i think thisGraphics.SetBinding(IsEnabledProperty, new Binding(nameof(BaseGraphicsCP.IsEnabled))); thisGraphics.SetBinding(NumberPieceXF.NumberValueProperty, new Binding(nameof(NumberPieceCP.NumberValue))); thisGraphics.SendPiece(thisPiece); }