private Cell CreateStepper(string text, string binding) { var cell = new ViewCell(); var layout = new StackLayout { Orientation = StackOrientation.Horizontal, Margin = 15 }; layout.Children.Add(new Label { Text = text, VerticalOptions = LayoutOptions.Center }); var valueLabel = new Label(); valueLabel.TextColor = Utility.PRIMARY_COLOR; valueLabel.SetBinding(Label.TextProperty, binding); valueLabel.HorizontalOptions = LayoutOptions.EndAndExpand; valueLabel.VerticalOptions = LayoutOptions.Center; valueLabel.FontSize = 20; valueLabel.Margin = 5; layout.Children.Add(valueLabel); var stepper = new Stepper(); stepper.SetBinding(Stepper.ValueProperty, binding); stepper.HorizontalOptions = LayoutOptions.End; stepper.VerticalOptions = LayoutOptions.Center; layout.Children.Add(stepper); cell.View = layout; return(cell); }
private StackLayout ConstructTimerSection() { var TimeLimitLabel = new Label { Text = string.Format("{0}:00", _timer.timeLimitMinutes.ToString()), FontSize = 30, HorizontalTextAlignment = TextAlignment.Center }; TimeLimitLabel.SetBinding(Label.TextProperty, "timeLimitMinutes"); var TimeLimitStepper = new Stepper { Value = _timer.timeLimitMinutes, Minimum = 0, Maximum = 60, Increment = 1, HorizontalOptions = LayoutOptions.Center }; TimeLimitStepper.SetBinding(Stepper.ValueProperty, "timeLimitMinutes"); var CurrentTimer = new Label { Text = _timer.time, HorizontalTextAlignment = TextAlignment.Center, FontSize = 60 }; CurrentTimer.SetBinding(Label.TextProperty, "time"); var Task = new Entry { Text = _timer.task, Placeholder = "Enter a name for your task.", HorizontalTextAlignment = TextAlignment.Center }; Task.SetBinding(Entry.TextProperty, "text"); var ProgressBar = new ProgressBar { Progress = 0.0 }; ProgressBar.SetBinding(ProgressBar.ProgressProperty, "currentProgress"); var TimerSection = new StackLayout { Children = { TimeLimitLabel, TimeLimitStepper, CurrentTimer, Task, ProgressBar } }; return(TimerSection); }
public RotationDemoPage() { this.Title = "Rotation"; // Label to be transformed. Label label = new Label { Text = "ROTATION", FontSize = 50, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; // Label and Slider for Rotation property. Label rotationSliderValue = new Label { YAlign = TextAlignment.Center }; Grid.SetRow(rotationSliderValue, 0); Grid.SetColumn(rotationSliderValue, 0); Slider rotationSlider = new Slider { Maximum = 360 }; Grid.SetRow(rotationSlider, 0); Grid.SetColumn(rotationSlider, 1); // Set Bindings. rotationSliderValue.BindingContext = rotationSlider; rotationSliderValue.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.OneWay, null, null, "Rotation = {0:F0}\u00B0")); rotationSlider.BindingContext = label; rotationSlider.SetBinding(Slider.ValueProperty, new Binding("Rotation", BindingMode.TwoWay)); // Label and Slider for AnchorX property. Label anchorxStepperValue = new Label { YAlign = TextAlignment.Center }; Grid.SetRow(anchorxStepperValue, 1); Grid.SetColumn(anchorxStepperValue, 0); Stepper anchorxStepper = new Stepper { Maximum = 2, Minimum = -1, Increment = 0.5 }; Grid.SetRow(anchorxStepper, 1); Grid.SetColumn(anchorxStepper, 1); // Set bindings. anchorxStepperValue.BindingContext = anchorxStepper; anchorxStepperValue.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.OneWay, null, null, "AnchorX = {0:F1}")); anchorxStepper.BindingContext = label; anchorxStepper.SetBinding(Stepper.ValueProperty, new Binding("AnchorX", BindingMode.TwoWay)); // Label and Slider for AnchorY property. Label anchoryStepperValue = new Label { YAlign = TextAlignment.Center }; Grid.SetRow(anchoryStepperValue, 2); Grid.SetColumn(anchoryStepperValue, 0); Stepper anchoryStepper = new Stepper { Maximum = 2, Minimum = -1, Increment = 0.5 }; Grid.SetRow(anchoryStepper, 2); Grid.SetColumn(anchoryStepper, 1); // Set bindings. anchoryStepperValue.BindingContext = anchoryStepper; anchoryStepperValue.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.OneWay, null, null, "AnchorY = {0:F1}")); anchoryStepper.BindingContext = label; anchoryStepper.SetBinding(Stepper.ValueProperty, new Binding("AnchorY", BindingMode.TwoWay)); // Assemble the page. this.Content = new StackLayout { Children = { label, new Grid { Padding = 10, RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto } }, ColumnDefinitions = { new ColumnDefinition { Width = GridLength.Auto }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } }, Children = { rotationSliderValue, rotationSlider, anchorxStepperValue, anchorxStepper, anchoryStepperValue, anchoryStepper } } } }; }
public VCell_Venda_Produto() { box_corProduto = new BoxView() { Margin = 5 }; l_nomeProduto = new Label() { VerticalTextAlignment = TextAlignment.Center, FontAttributes = FontAttributes.Bold }; l_valor = new Label() { VerticalTextAlignment = TextAlignment.Center }; l_totalValor = new Label() { VerticalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.End }; l_quantidade = new Label() { VerticalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.EndAndExpand }; b_diminuir = new Button() { TextColor = Color.White, BackgroundColor = Color.IndianRed, Text = "Remover", HorizontalOptions = LayoutOptions.EndAndExpand }; st_quantidade = new Stepper() { HorizontalOptions = LayoutOptions.EndAndExpand }; clickBackground = new TapGestureRecognizer(); clickBackground.Tapped += ClickBackground_Tapped; l_quantidade.GestureRecognizers.Add(clickBackground); box_corProduto.SetBinding(BoxView.ColorProperty, "CorProduto"); l_nomeProduto.SetBinding(Label.TextProperty, "Descricao"); l_nomeProduto.SetBinding(Label.TextColorProperty, "CorFont"); l_valor.SetBinding(Label.TextProperty, "Valor", stringFormat: "R${0}"); l_valor.SetBinding(Label.TextColorProperty, "CorFont"); l_totalValor.SetBinding(Label.TextProperty, "Total", stringFormat: "Total R${0}"); l_totalValor.SetBinding(Label.TextColorProperty, "CorFont"); l_quantidade.SetBinding(Label.TextProperty, "Quantidade", stringFormat: "Qtd {0}"); l_quantidade.SetBinding(Label.TextColorProperty, "CorFont"); st_quantidade.SetBinding(Stepper.ValueProperty, "Quantidade"); st_quantidade.ValueChanged += St_quantidade_ValueChanged; b_diminuir.Clicked += B_diminuir_Clicked; sl_lado_hori_A = new StackLayout() { Orientation = StackOrientation.Horizontal, Children = { box_corProduto, l_nomeProduto, l_valor } }; sl_principal = new StackLayout() { Orientation = StackOrientation.Horizontal, Children = { sl_lado_hori_A, l_quantidade, b_diminuir } }; sl_principal.SetBinding(StackLayout.BackgroundColorProperty, "CorBackground"); sl_lado_hori_A.GestureRecognizers.Add(clickBackground); this.View = sl_principal; }
public ScaleRotate() { Label label = new Label { Text = "SCALE AND\nROTATE", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; // Label and Slider for Scale property. Label scaleSliderValue = new Label { VerticalTextAlignment = TextAlignment.Center }; Grid.SetRow(scaleSliderValue, 0); Grid.SetColumn(scaleSliderValue, 0); Slider scaleSlider = new Slider { Maximum = 10 }; Grid.SetRow(scaleSlider, 0); Grid.SetColumn(scaleSlider, 1); // Set Bindings. scaleSliderValue.BindingContext = scaleSlider; scaleSliderValue.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.OneWay, null, null, "Scale = {0:F1}")); scaleSlider.BindingContext = label; scaleSlider.SetBinding(Slider.ValueProperty, new Binding("Scale", BindingMode.TwoWay)); // Label and Slider for ScaleX property. Label scaleXSliderValue = new Label { VerticalTextAlignment = TextAlignment.Center }; Grid.SetRow(scaleXSliderValue, 1); Grid.SetColumn(scaleXSliderValue, 0); Slider scaleXSlider = new Slider { Maximum = 10 }; Grid.SetRow(scaleXSlider, 1); Grid.SetColumn(scaleXSlider, 1); // Set Bindings. scaleXSliderValue.BindingContext = scaleXSlider; scaleXSliderValue.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.OneWay, null, null, "ScaleX = {0:F1}")); scaleXSlider.BindingContext = label; scaleXSlider.SetBinding(Slider.ValueProperty, new Binding("ScaleX", BindingMode.TwoWay)); // Label and Slider for Rotation property. Label rotationSliderValue = new Label { VerticalTextAlignment = TextAlignment.Center }; Grid.SetRow(rotationSliderValue, 2); Grid.SetColumn(rotationSliderValue, 0); Slider rotationSlider = new Slider { Maximum = 360 }; Grid.SetRow(rotationSlider, 2); Grid.SetColumn(rotationSlider, 1); // Set Bindings. rotationSliderValue.BindingContext = rotationSlider; rotationSliderValue.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.OneWay, null, null, "Rotation = {0:F0}")); rotationSlider.BindingContext = label; rotationSlider.SetBinding(Slider.ValueProperty, new Binding("Rotation", BindingMode.TwoWay)); // Label and Slider for AnchorX property. Label anchorxStepperValue = new Label { VerticalTextAlignment = TextAlignment.Center }; Grid.SetRow(anchorxStepperValue, 3); Grid.SetColumn(anchorxStepperValue, 0); Stepper anchorxStepper = new Stepper { Maximum = 2, Minimum = -1, Increment = 0.5 }; Grid.SetRow(anchorxStepper, 3); Grid.SetColumn(anchorxStepper, 1); // Set bindings. anchorxStepperValue.BindingContext = anchorxStepper; anchorxStepperValue.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.OneWay, null, null, "AnchorX = {0:F1}")); anchorxStepper.BindingContext = label; anchorxStepper.SetBinding(Stepper.ValueProperty, new Binding("AnchorX", BindingMode.TwoWay)); // Label and Slider for AnchorY property. Label anchoryStepperValue = new Label { VerticalTextAlignment = TextAlignment.Center }; Grid.SetRow(anchoryStepperValue, 4); Grid.SetColumn(anchoryStepperValue, 0); Stepper anchoryStepper = new Stepper { Maximum = 2, Minimum = -1, Increment = 0.5 }; Grid.SetRow(anchoryStepper, 4); Grid.SetColumn(anchoryStepper, 1); // Set bindings. anchoryStepperValue.BindingContext = anchoryStepper; anchoryStepperValue.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.OneWay, null, null, "AnchorY = {0:F1}")); anchoryStepper.BindingContext = label; anchoryStepper.SetBinding(Stepper.ValueProperty, new Binding("AnchorY", BindingMode.TwoWay)); // Assemble the page. Content = new StackLayout { Children = { label, new Grid { Padding = 10, RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, }, ColumnDefinitions = { new ColumnDefinition { Width = GridLength.Auto }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } }, Children = { scaleSliderValue, scaleSlider, scaleXSliderValue, scaleXSlider, rotationSliderValue, rotationSlider, anchorxStepperValue, anchorxStepper, anchoryStepperValue, anchoryStepper } } } }; }
public SliderStepperSwitchBindingsPage() { // Create a Slider. Slider slider = new Slider { VerticalOptions = LayoutOptions.EndAndExpand }; // Create a Label to display the Slider value. Label sliderValueLabel = new Label { Font = Font.SystemFontOfSize(NamedSize.Large), VerticalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.Center }; // Create a Stepper. Stepper stepper = new Stepper { VerticalOptions = LayoutOptions.EndAndExpand, HorizontalOptions = LayoutOptions.Center }; // Create a Label to display the Stepper value. Label stepperValueLabel = new Label { Font = Font.SystemFontOfSize(NamedSize.Large), VerticalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.Center, }; // Create a Switch. Switch switcher = new Switch { IsToggled = true, VerticalOptions = LayoutOptions.EndAndExpand, HorizontalOptions = LayoutOptions.Center }; // Create a Label to display the Switch value. Label switchToggledLabel = new Label { Font = Font.SystemFontOfSize(NamedSize.Large), VerticalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.Center }; // Put them all in a StackLayout. this.Content = new StackLayout { Children = { slider, sliderValueLabel, stepper, stepperValueLabel, switcher, switchToggledLabel, } }; sliderValueLabel.BindingContext = slider; sliderValueLabel.SetBinding(Label.OpacityProperty, "Value"); slider.BindingContext = switcher; slider.SetBinding(Slider.IsEnabledProperty, "IsToggled"); stepper.BindingContext = switcher; stepper.SetBinding(Stepper.IsEnabledProperty, "IsToggled"); sliderValueLabel.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.Default, null, null, "The Slider value is {0:F2}")); stepperValueLabel.BindingContext = stepper; stepperValueLabel.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.Default, null, null, "The Stepper value is {0}")); switchToggledLabel.BindingContext = switcher; switchToggledLabel.SetBinding(Label.TextProperty, new Binding("IsToggled", BindingMode.Default, null, null, "The Switch is toggled {0}")); }
private ContentPage CreateTab1() { var tab1Layout = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { new Label { HorizontalTextAlignment = TextAlignment.Center, Text = "Xamarin Forms Tab Badge Sample", FontSize = 14, FontAttributes = FontAttributes.Bold }, } }; var stepper = new Stepper { Increment = 1, Maximum = 111, Minimum = 0, VerticalOptions = LayoutOptions.Center }; stepper.SetBinding(Stepper.ValueProperty, nameof(Tab1ViewModel.CountValue), BindingMode.TwoWay); var grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.Children.Add(new Label { Text = "Increment / Decrement Value: ", HorizontalTextAlignment = TextAlignment.End, VerticalTextAlignment = TextAlignment.Center }, 0, 0); grid.Children.Add(stepper, 1, 0); tab1Layout.Children.Add(grid); var buttonChangeColor = new Button { Text = "Change Color" }; buttonChangeColor.SetBinding(Button.CommandProperty, nameof(Tab1ViewModel.ChangeColorCommand)); tab1Layout.Children.Add(buttonChangeColor); var buttonChangeTextColor = new Button { Text = "Change Text Color" }; buttonChangeTextColor.SetBinding(Button.CommandProperty, nameof(Tab1ViewModel.ChangeTextColorCommand)); tab1Layout.Children.Add(buttonChangeTextColor); var buttonChangeFontAttributes = new Button { Text = "Change Font Attributes" }; buttonChangeFontAttributes.SetBinding(Button.CommandProperty, nameof(Tab1ViewModel.ChangeFontAttributesCommand)); tab1Layout.Children.Add(buttonChangeFontAttributes); var buttonChangePosition = new Button { Text = "Change Position" }; buttonChangePosition.SetBinding(Button.CommandProperty, nameof(Tab1ViewModel.ChangePositionCommand)); tab1Layout.Children.Add(buttonChangePosition); var buttonAddTab = new Button() { Text = "Add tab" }; buttonAddTab.Clicked += ButtonAddTab_Clicked; var buttonRemoveTab = new Button() { Text = "Remove tab" }; buttonRemoveTab.Clicked += ButtonRemoveTab_Clicked; grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.Children.Add(buttonAddTab, 0, 0); grid.Children.Add(buttonRemoveTab, 1, 0); tab1Layout.Children.Add(grid); grid = new Grid { RowSpacing = 0 }; grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); var leftStepper = new Stepper { Increment = 1, Minimum = -50, Maximum = 50 }; leftStepper.SetBinding(Stepper.ValueProperty, nameof(Tab1ViewModel.MarginLeft), BindingMode.TwoWay); var leftMarginLabel = new Label(); leftMarginLabel.SetBinding(Label.TextProperty, nameof(Tab1ViewModel.MarginLeft), stringFormat: "Left: {0}"); grid.Children.Add(leftMarginLabel, 0, 0); grid.Children.Add(leftStepper, 0, 1); var topStepper = new Stepper { Increment = 1, Minimum = -50, Maximum = 50 }; topStepper.SetBinding(Stepper.ValueProperty, nameof(Tab1ViewModel.MarginTop), BindingMode.TwoWay); var topMarginLabel = new Label(); topMarginLabel.SetBinding(Label.TextProperty, nameof(Tab1ViewModel.MarginTop), stringFormat: "Top: {0}"); grid.Children.Add(topMarginLabel, 1, 0); grid.Children.Add(topStepper, 1, 1); var rightStepper = new Stepper { Increment = 1, Minimum = -50, Maximum = 50 }; rightStepper.SetBinding(Stepper.ValueProperty, nameof(Tab1ViewModel.MarginRight), BindingMode.TwoWay); var rightMarginLabel = new Label(); rightMarginLabel.SetBinding(Label.TextProperty, nameof(Tab1ViewModel.MarginRight), stringFormat: "Right: {0}"); grid.Children.Add(rightMarginLabel, 0, 2); grid.Children.Add(rightStepper, 0, 3); var bottomStepper = new Stepper { Increment = 1, Minimum = -50, Maximum = 50 }; bottomStepper.SetBinding(Stepper.ValueProperty, nameof(Tab1ViewModel.MarginBottom), BindingMode.TwoWay); var bottomMarginLabel = new Label(); bottomMarginLabel.SetBinding(Label.TextProperty, nameof(Tab1ViewModel.MarginBottom), stringFormat: "Bottom: {0}"); grid.Children.Add(bottomMarginLabel, 1, 2); grid.Children.Add(bottomStepper, 1, 3); tab1Layout.Children.Add(grid); var tab1 = new ContentPage { Title = "Tab1", Content = new ScrollView() { Content = tab1Layout } }; tab1.SetBinding(TabBadge.BadgeTextProperty, nameof(Tab1ViewModel.Count)); tab1.SetBinding(TabBadge.BadgeColorProperty, nameof(Tab1ViewModel.BadgeColor)); tab1.SetBinding(TabBadge.BadgeTextColorProperty, nameof(Tab1ViewModel.BadgeTextColor)); tab1.SetBinding(TabBadge.BadgeFontProperty, nameof(Tab1ViewModel.BadgeFont)); tab1.SetBinding(TabBadge.BadgePositionProperty, nameof(Tab1ViewModel.Position)); tab1.SetBinding(TabBadge.BadgeMarginProperty, nameof(Tab1ViewModel.Margin)); tab1.BindingContext = new Tab1ViewModel(); return(tab1); }
public ScaleXDemoPage() { this.Title = "ScaleX"; // Label to be transformed. Label label = new Label { Text = "SCALEX", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; // Label and Slider for ScaleX property. Label scaleSliderValue = new Label { VerticalTextAlignment = TextAlignment.Center }; Grid.SetRow(scaleSliderValue, 0); Grid.SetColumn(scaleSliderValue, 0); Slider scaleSlider = new Slider { Maximum = 10 }; Grid.SetRow(scaleSlider, 0); Grid.SetColumn(scaleSlider, 1); // Set Bindings. scaleSliderValue.BindingContext = scaleSlider; scaleSliderValue.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.OneWay, null, null, "ScaleX = {0:F1}")); scaleSlider.BindingContext = label; scaleSlider.SetBinding(Slider.ValueProperty, new Binding("ScaleX", BindingMode.TwoWay)); // Label and Slider for AnchorX property. Label anchorxStepperValue = new Label { VerticalTextAlignment = TextAlignment.Center }; Grid.SetRow(anchorxStepperValue, 1); Grid.SetColumn(anchorxStepperValue, 0); Stepper anchorxStepper = new Stepper { Maximum = 2, Minimum = -1, Increment = 0.5 }; Grid.SetRow(anchorxStepper, 1); Grid.SetColumn(anchorxStepper, 1); // Set bindings. anchorxStepperValue.BindingContext = anchorxStepper; anchorxStepperValue.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.OneWay, null, null, "AnchorX = {0:F1}")); anchorxStepper.BindingContext = label; anchorxStepper.SetBinding(Stepper.ValueProperty, new Binding("AnchorX", BindingMode.TwoWay)); // Label and Slider for AnchorY property. Label anchoryStepperValue = new Label { VerticalTextAlignment = TextAlignment.Center }; Grid.SetRow(anchoryStepperValue, 2); Grid.SetColumn(anchoryStepperValue, 0); Stepper anchoryStepper = new Stepper { Maximum = 2, Minimum = -1, Increment = 0.5 }; Grid.SetRow(anchoryStepper, 2); Grid.SetColumn(anchoryStepper, 1); // Set bindings. anchoryStepperValue.BindingContext = anchoryStepper; anchoryStepperValue.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.OneWay, null, null, "AnchorY = {0:F1}")); anchoryStepper.BindingContext = label; anchoryStepper.SetBinding(Stepper.ValueProperty, new Binding("AnchorY", BindingMode.TwoWay)); // Assemble the page. this.Content = new StackLayout { Children = { label, new Grid { Padding = 10, RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(0.5, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(0.5, GridUnitType.Star) } }, Children = { scaleSliderValue, scaleSlider, anchorxStepperValue, anchorxStepper, anchoryStepperValue, anchoryStepper } } } }; }
private void InitTableView() { var bindingContext = BindingContext as VisitResultViewModel; int paddingLeft = Convert.ToInt32(Application.Current.Resources["paddingLeftFormViewCell"]); TableView tableView = new TableView { Intent = TableIntent.Form, Root = new TableRoot("Esito visita"), HasUnevenRows = true }; tableView.SetBinding(TableView.IsVisibleProperty, nameof(bindingContext.IsReady)); #region Clients List Picker Picker clientsListPicker = new Picker(); clientsListPicker.Title = "Seleziona cliente"; clientsListPicker.SetBinding(Picker.ItemsSourceProperty, nameof(bindingContext.ClientsList)); clientsListPicker.SetBinding(Picker.SelectedItemProperty, nameof(bindingContext.ClientName)); tableView.Root.Add(new TableSection("Cliente") { new ViewCell() { View = clientsListPicker } }); #endregion #region Contact EntryCell contactName = new EntryCell(); contactName.Label = "Contatto:"; contactName.Placeholder = "Nome Contatto"; contactName.SetBinding(EntryCell.TextProperty, nameof(bindingContext.ContactName)); EntryCell contactPhone = new EntryCell(); contactPhone.Label = "Telefono:"; contactPhone.Placeholder = "Numero di telefono"; contactPhone.Keyboard = Keyboard.Telephone; contactPhone.SetBinding(EntryCell.TextProperty, nameof(bindingContext.ContactPhone)); EntryCell contactEmail = new EntryCell(); contactEmail.Label = "Email:"; contactEmail.Placeholder = "Indirizzo email"; contactEmail.Keyboard = Keyboard.Email; contactEmail.SetBinding(EntryCell.TextProperty, nameof(bindingContext.ContactEmail)); EntryCell contactWebSite = new EntryCell(); contactWebSite.Label = "Web:"; contactWebSite.Placeholder = "Indirizzo sito web"; contactWebSite.Keyboard = Keyboard.Url; contactWebSite.SetBinding(EntryCell.TextProperty, nameof(bindingContext.ContactWebSite)); tableView.Root.Add(new TableSection("Contatto") { contactName, contactPhone, contactEmail, contactWebSite }); #endregion #region Visit Date and Time DatePicker visitDatePicker = new DatePicker(); visitDatePicker.SetBinding(DatePicker.DateProperty, nameof(bindingContext.VisitDate)); TimePicker visitTimePicker = new TimePicker(); visitTimePicker.SetBinding(TimePicker.TimeProperty, nameof(bindingContext.VisitTime)); tableView.Root.Add(new TableSection("Data e Ora Visita") { new ViewCell() { View = new StackLayout() { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.Center, Children = { visitDatePicker, visitTimePicker } } } }); #endregion #region Visit Interview #region Is Interested SwitchCell isInterested = new SwitchCell() { Text = "Interessato" }; isInterested.SetBinding(SwitchCell.OnProperty, nameof(bindingContext.IsInterested)); #endregion #region Quantity Entry quantity = new Entry() { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.End }; quantity.SetBinding(Entry.TextProperty, nameof(bindingContext.Quantity)); Stepper quantityStepper = new Stepper(); quantityStepper.SetBinding(Stepper.ValueProperty, nameof(bindingContext.Quantity)); #endregion #region Rating Entry rating = new Entry() { HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.End }; rating.SetBinding(Entry.TextProperty, nameof(bindingContext.Rating)); Slider ratingSlider = new Slider() { Minimum = 0, Maximum = 10 }; ratingSlider.SetBinding(Slider.ValueProperty, nameof(bindingContext.Rating)); ratingSlider.HorizontalOptions = LayoutOptions.FillAndExpand; #endregion #region Comment Editor comment = new Editor(); comment.SetBinding(Editor.TextProperty, nameof(bindingContext.Comment)); comment.HorizontalOptions = LayoutOptions.FillAndExpand; comment.VerticalOptions = LayoutOptions.FillAndExpand; #endregion #region Add controls to the Table Section tableView.Root.Add(new TableSection("Intervista") { isInterested, new ViewCell() { View = new StackLayout() { Orientation = StackOrientation.Horizontal, Padding = new Thickness() { Left = paddingLeft }, Children = { new Label() { Text = "Quantità", HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center, }, quantity, quantityStepper } } }, new ViewCell() { View = new StackLayout() { Orientation = StackOrientation.Horizontal, Padding = new Thickness() { Left = paddingLeft }, Children = { new Label() { Text = "Valutazione", HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center, }, rating, ratingSlider } } }, new ViewCell() { View = new StackLayout() { Orientation = StackOrientation.Horizontal, Padding = new Thickness() { Left = paddingLeft }, Children = { new Label() { Text = "Commento", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, }, comment } } } }); #endregion #endregion #region Addresses //List<AddressViewCell> addressViewsList = new List<AddressViewCell>(); //TableSection addressesTableSection = new TableSection("Indirizzi"); //foreach (AddressModel addressModel in bindingContext.AddressesList) //{ // addressesTableSection.Add(new AddressViewCell() { BindingContext = addressModel }); //} //tableView.Root.Add(addressesTableSection); Button btnAddAddress = new Button() { Text = "Aggiungi indirizzo" }; btnAddAddress.Clicked += BtnAddAddress_Clicked; //stackLayout.Children.Add(btnAddAddress); ListView addressesViews = new ListView(); addressesViews.SetBinding(ListView.ItemsSourceProperty, nameof(bindingContext.AddressesList)); addressesViews.ItemTemplate = new DataTemplate(typeof(AddressViewCell)); addressesViews.RowHeight = 200; //stackLayout.Children.Add(addressesViews); tableView.Root.Add(new TableSection("Indirizzi") { new ViewCell() { View = btnAddAddress }, new ViewCell() { View = addressesViews } }); #endregion stackLayout.Children.Add(tableView); }
public SettingsPage() { matchCountLabel = new Label { }; matchCountLabel.SetBinding(Label.TextProperty, new Binding("MatchCount", stringFormat: "Liczba meczy: {0}")); Stepper matchStepper = new Stepper { Value = 3, Minimum = 1, Maximum = 3, Increment = 1 }; matchStepper.SetBinding(Stepper.ValueProperty, new Binding("MatchCount")); matchTimeLabel = new Label { }; matchTimeLabel.SetBinding(Label.TextProperty, new Binding("MatchTime", stringFormat: "Czas trwania meczu: {0}")); Stepper matchTimeStepper = new Stepper { Value = 5, Minimum = 1, Maximum = 30, Increment = 1 }; matchTimeStepper.SetBinding(Stepper.ValueProperty, new Binding("MatchTime")); goalLimitLabel = new Label { }; goalLimitLabel.SetBinding(Label.TextProperty, new Binding("GoalLimit", stringFormat: "Limit bramek: {0}")); Switch goalLimitSwitch = new Switch(); goalLimitSwitch.SetBinding(Switch.IsToggledProperty, new Binding("IsGoalLimitEnabled")); goalLimitStepper = new Stepper { IsVisible = false, Value = 10, Minimum = 5, Maximum = 100, Increment = 1 }; goalLimitStepper.SetBinding(Stepper.IsVisibleProperty, new Binding("IsGoalLimitEnabled")); goalLimitStepper.SetBinding(Stepper.ValueProperty, new Binding("GoalLimit")); Content = new StackLayout { Children = { matchCountLabel, matchStepper, matchTimeLabel, matchTimeStepper, goalLimitLabel, goalLimitSwitch, goalLimitStepper } }; }