public void PopulateControls(Guess guess) { _thisStack.Children.Clear(); if (guess.YourBeads.Count == 0) { return; //maybe you don't need it at that moment (?) } if (guess.YourBeads.Count != 4) { throw new BasicBlankException("Only 4 are supported"); } guess.YourBeads.ForEach(bead => { //we may have to manually add to the special list (?) CirclePieceXF <EnumColorPossibilities> thisControl = new CirclePieceXF <EnumColorPossibilities>(); thisControl.SetBinding(CirclePieceXF <EnumColorPossibilities> .MainColorProperty, new Binding(nameof(Bead.UIColor))); thisControl.BindingContext = bead; thisControl.HeightRequest = GuessWidthHeight; thisControl.WidthRequest = GuessWidthHeight; thisControl.NeedsWhiteBorders = true; thisControl.CommandParameter = bead; thisControl.Init(); thisControl.SetName(nameof(GameBoardViewModel.ChangeMind)); GamePackageViewModelBinder.ManuelElements.Add(thisControl); //try this way. _thisStack.Children.Add(thisControl); }); }
public SolutionView(GlobalClass global) { if (global.Solution == null) { throw new BasicBlankException("No solution to even show"); } if (global.Solution.Count != 4) { throw new BasicBlankException("Must have 4 for the solution"); } StackLayout stack = new StackLayout() { Orientation = StackOrientation.Horizontal }; //this can be larger because nothing else is showing now at this point. global.Solution.ForEach(bead => { CirclePieceXF <EnumColorPossibilities> thisControl = new CirclePieceXF <EnumColorPossibilities>(); thisControl.SetBinding(CirclePieceXF <EnumColorPossibilities> .MainColorProperty, new Binding(nameof(Bead.UIColor))); thisControl.BindingContext = bead; thisControl.HeightRequest = GuessWidthHeight; thisControl.WidthRequest = GuessWidthHeight; //can experiment this time. thisControl.NeedsWhiteBorders = true; thisControl.Init(); stack.Children.Add(thisControl); }); Content = stack; }
public void Init(Guess thisGuess) { _thisStack = new StackLayout(); _thisStack.Orientation = StackOrientation.Horizontal; _thisStack.Spacing = 0; // at first, act like its nothing. int x; for (x = 1; x <= 4; x++) { CirclePieceXF <EnumColorPossibilities> thisCon = new CirclePieceXF <EnumColorPossibilities>(); thisCon.NeedsWhiteBorders = true; thisCon.HeightRequest = GuessWidthHeight; thisCon.WidthRequest = GuessWidthHeight; thisCon.Init(); _thisStack.Children.Add(thisCon); } Content = _thisStack; SetBinding(HowManyCompletelyCorrectProperty, new Binding(nameof(Guess.HowManyBlacks))); SetBinding(HowManySemiCorrectProperty, new Binding(nameof(Guess.HowManyAquas))); BindingContext = thisGuess; }