UIPickerView BordersPickerView; //the view for the picker public GeneralMaintenanceScreen() { //create screen Screen = new UIViewController(); Screen.View.BackgroundColor = UIColor.White; //1. create view //pages label PagesLabel = new UILabel(); PagesLabel.Text = "Number of pages:"; PagesLabel.TextColor = UIColor.Black; PagesLabel.TextAlignment = UITextAlignment.Left; //buttons label ButtonsLabel = new UILabel(); ButtonsLabel.Text = "Number of buttons:"; ButtonsLabel.TextColor = UIColor.Black; ButtonsLabel.TextAlignment = UITextAlignment.Left; //borders label BordersLabel = new UILabel(); BordersLabel.Text = "Borders thickness:"; BordersLabel.TextColor = UIColor.Black; BordersLabel.TextAlignment = UITextAlignment.Left; //buttons per page dropdown ButtonsPickerModel = new PickerModel(ButtonsNum); ButtonsPickerModel.PickerChanged += (object sender, PickerChangedEventArgs e) => { Debug.WriteLine("picker changed"); Debug.WriteLine("value selected" + e.SelectedValue); ButtonsPerPage = Int32.Parse(e.SelectedValue.ToString()); }; //add picker model to ui picker and some styling ButtonsPickerView = new UIPickerView(); ButtonsPickerView.Model = ButtonsPickerModel; ButtonsPickerView.ShowSelectionIndicator = true; ButtonsPickerView.BackgroundColor = UIColor.White; ButtonsPickerView.Layer.BorderColor = UIColor.Gray.CGColor; ButtonsPickerView.Layer.BorderWidth = 4.5f; ButtonsPickerView.Layer.CornerRadius = ButtonCornerRadius; //pages dropdown //create picker model, and add function event when it changes //function will change the text fields value PagesPickerModel = new PickerModel(PagesNum); PagesPickerModel.PickerChanged += (object sender, PickerChangedEventArgs e) => { Debug.WriteLine("picker changed"); Debug.WriteLine("value selected" + e.SelectedValue); NumberOfPages = Int32.Parse(e.SelectedValue.ToString()); }; //add picker model to ui picker and some styling PagesPickerView = new UIPickerView(); PagesPickerView.Model = PagesPickerModel; PagesPickerView.ShowSelectionIndicator = true; //PagesPickerView.Frame = new CoreGraphics.CGRect(250, 150, 60, 60); PagesPickerView.BackgroundColor = UIColor.White; PagesPickerView.Layer.BorderColor = UIColor.Gray.CGColor; PagesPickerView.Layer.BorderWidth = 4.5f; PagesPickerView.Layer.CornerRadius = ButtonCornerRadius; //borders dropdown //create picker model, and add function event when it changes //function will change the text fields value BordersPickerModel = new PickerModel(BordersNum); BordersPickerModel.PickerChanged += (object sender, PickerChangedEventArgs e) => { Debug.WriteLine("picker changed"); Debug.WriteLine("value selected" + e.SelectedValue); BordersThickness = Int32.Parse(e.SelectedValue.ToString()); }; //add picker model to ui picker and some styling BordersPickerView = new UIPickerView(); BordersPickerView.Model = BordersPickerModel; BordersPickerView.ShowSelectionIndicator = true; BordersPickerView.BackgroundColor = UIColor.White; BordersPickerView.Layer.BorderColor = UIColor.Gray.CGColor; BordersPickerView.Layer.BorderWidth = 4.5f; BordersPickerView.Layer.CornerRadius = ButtonCornerRadius; //create back button BackButton = new UIButton(); BackButton.BackgroundColor = UIColor.Red; BackButton.TouchUpInside += CloseScreen; BackButton.SetTitle("Back", UIControlState.Normal); BackButton.SetTitleColor(UIColor.Black, UIControlState.Normal); BackButton.Layer.BorderColor = ButtonBorderColour.CGColor; BackButton.Layer.BorderWidth = BordersThickness; BackButton.BackgroundColor = ButtonBackgroundColour; BackButton.Layer.CornerRadius = ButtonCornerRadius; //create save button SaveButton = new UIButton(); SaveButton.BackgroundColor = UIColor.Red; SaveButton.TouchUpInside += Save; SaveButton.SetTitle("Save", UIControlState.Normal); SaveButton.SetTitleColor(UIColor.Black, UIControlState.Normal); SaveButton.Layer.BorderColor = ButtonBorderColour.CGColor; SaveButton.Layer.BorderWidth = BordersThickness; SaveButton.BackgroundColor = ButtonBackgroundColour; SaveButton.Layer.CornerRadius = ButtonCornerRadius; //2. add view to parent view Screen.View.Add(PagesLabel); Screen.View.Add(ButtonsLabel); Screen.View.Add(ButtonsPickerView); Screen.View.Add(PagesPickerView); Screen.View.Add(BackButton); Screen.View.Add(SaveButton); Screen.View.Add(BordersLabel); Screen.View.Add(BordersPickerView); //3. call method on parent view Screen.View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); //4. add constraints Screen.View.AddConstraints( PagesLabel.WithSameTop(BackButton), PagesLabel.AtLeftOf(Screen.View, 70), PagesLabel.WithRelativeWidth(Screen.View, 0.2f), //PagesLabel.Width().EqualTo(150), PagesLabel.Height().EqualTo(45), ButtonsLabel.WithSameTop(SaveButton), ButtonsLabel.WithSameLeft(PagesLabel), ButtonsLabel.WithSameWidth(PagesLabel), ButtonsLabel.WithSameHeight(PagesLabel), BordersLabel.Below(SaveButton, 80),// BordersLabel.WithSameLeft(PagesLabel), BordersLabel.WithSameWidth(PagesLabel), BordersLabel.WithSameHeight(PagesLabel), ButtonsPickerView.WithSameTop(ButtonsLabel), ButtonsPickerView.Left().EqualTo().RightOf(ButtonsLabel).Plus(30), ButtonsPickerView.Width().EqualTo(60), ButtonsPickerView.Height().EqualTo(60), PagesPickerView.WithSameTop(PagesLabel), PagesPickerView.WithSameLeft(ButtonsPickerView), PagesPickerView.WithSameWidth(ButtonsPickerView), PagesPickerView.WithSameHeight(ButtonsPickerView), BordersPickerView.WithSameTop(BordersLabel),// BordersPickerView.WithSameLeft(ButtonsPickerView), BordersPickerView.WithSameWidth(ButtonsPickerView), BordersPickerView.WithSameHeight(ButtonsPickerView), BackButton.AtTopOf(Screen.View, UIApplication.SharedApplication.StatusBarFrame.Height + 70), BackButton.AtRightOf(Screen.View, 70), BackButton.WithRelativeWidth(Screen.View, 0.2f), BackButton.Height().EqualTo(100), SaveButton.Below(BackButton, 80), SaveButton.WithSameRight(BackButton), SaveButton.WithSameWidth(BackButton), SaveButton.WithSameHeight(BackButton) ); }