public SettingsPage ()
		{
			var svm = new SettingsViewModel { 
				AirplaneMode = true
			};
			BindingContext = svm;

			var airplaneModeCell = new SwitchCell {Text = "Airplane Mode"};
			airplaneModeCell.SetBinding(SwitchCell.OnProperty, "AirplaneMode");

			Title = "Settings";
			Content = new TableView {
				Root = new TableRoot {
					new TableSection (" ") {
						airplaneModeCell,
						new SwitchCell {Text = "Notifications"}
					},
					new TableSection (" ") {
						new EntryCell { Label="Login", Placeholder = "username" }
						, new EntryCell {Label="Password", Placeholder = "password" }
					},
					new TableSection ("Silent") {
						new SwitchCell {Text = "Vibrate", },
						new ViewCell { View = new Slider() }
					},
				
					new TableSection ("Ring") {
						new SwitchCell {Text = "New Voice Mail"},
						new SwitchCell {Text = "New Mail", On = true}
					},
				},
			};
		}
        public App()
        {
            ToggleIt = new Command (() => IsToggled = !IsToggled);

            SwitchCell mySwitch = new SwitchCell ();
            mySwitch.SetBinding (SwitchCell.OnProperty , "IsToggled", 0);
            var myButton = new Button(){
                Text="CLICK IT! CLICK IT! CLICK IT!  YOU KNOW YOU WANT TO",
                Command = ToggleIt};

            MainPage = new ContentPage {
                BindingContext = this,
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Center,
                    Children = {
                        myButton,
                        new TableView
                        {
                            Intent = TableIntent.Form,
                            Root = new TableRoot
                            {
                                new TableSection
                                {
                                    mySwitch
                                }
                            }
                        }
                    }
                }
            };
        }
 internal static Cell BoolCell (PropertyInfo property, IContact context, Page parent = null)
 {
     var label = CreateLabel(property);
     var switchCell = new SwitchCell();
     switchCell.SetValue(SwitchCell.TextProperty, label);
     switchCell.SetBinding(SwitchCell.OnProperty, new Binding(property.Name, BindingMode.TwoWay));
     switchCell.BindingContext = context;
     return switchCell;
 }
Exemplo n.º 4
0
        public SwitchPageCS()
        {
            SwitchPageViewModel vm = new SwitchPageViewModel();
            BindingContext = vm;

            var sw0 = new SwitchCell { Text = "Toggle sw1 & sw2" };
            sw0.SetBinding(SwitchCell.OnProperty, "SwAllValue", BindingMode.OneWayToSource);
            var sw1 = new SwitchCell { Text = "Toggle sw1" };
            sw1.SetBinding(SwitchCell.OnProperty, "Sw1Value", BindingMode.TwoWay);
            var sw2 = new SwitchCell { Text = "Toggle sw2" };
            sw2.SetBinding(SwitchCell.OnProperty, "Sw2Value", BindingMode.TwoWay);
            var tc1 = new TextCell { Text = "sw1 value" };
            tc1.SetBinding(TextCell.DetailProperty, "Sw1Value");
            var tc2 = new TextCell { Text = "sw2 value" };
            tc2.SetBinding(TextCell.DetailProperty, "Sw2Value");

            var tv = new TableView
            {
                Intent = TableIntent.Menu,
                Root = new TableRoot
                {
                    new TableSection("Toggle all")
                    {
                        sw0,
                    },

                    new TableSection("Toggle each")
                    {
                        sw1,
                        sw2,
                    },
                    new TableSection("Values of ViewModel")
                    {
                        tc1,
                        tc2,
                    }
                }
            };

            Content = new StackLayout
            {
                Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0),
                Children =
                {
                    tv,
                }
            };
        }
Exemplo n.º 5
0
        public TestPage()
        {
            this.BindingContext = new TestPageViewModel();

            var ed = new Editor { Text = "BindingTo TextValue" };
            ed.SetBinding(Editor.TextProperty, "TextValue", mode: BindingMode.OneWayToSource);
            var lb = new Label { Text = "" };
            lb.SetBinding(Label.TextProperty, "TextValue");

            var sw = new Switch();
            sw.SetBinding(Switch.IsToggledProperty, "BoolValue", mode: BindingMode.TwoWay);

            var sc = new SwitchCell { Text = "BindingTo BoolValue" };
            sc.SetBinding(SwitchCell.OnProperty, "BoolValue", mode: BindingMode.TwoWay);

            var tc = new TextCell { Text = "" };
            tc.SetBinding(TextCell.TextProperty, "BoolValue", stringFormat:"Value: {0}");

            var tv = new TableView
            {
                Intent = TableIntent.Settings,
                Root = new TableRoot
                {
                    new TableSection("TableView")
                    {
                        sc,
                        tc,
                    },
                }
            };

            Content = new StackLayout
            {
                Padding = 20,
                Children = {
                    new Label {
                        Text = "INotifyPropertyChanged Test",
                        FontSize = 30,
                    },
                    ed,
                    lb,
                    sw,
                    tv,
                }
            };
        }
		public SettingsPage(LanesViewModel viewModel)
		{
			BindingContext = viewModel;

			#region create the IsOpen Switch
			var isOpenSwitch = new SwitchCell
			{
				Text = "Is Open"
			};
			isOpenSwitch.SetBinding(SwitchCell.OnProperty,"LaneTappedIsOpen");
			#endregion

			#region Create the Needs Maintenance Switch
			var needsMaintenanceSwitch = new SwitchCell
			{
				Text = "Needs Maintenance"
			};
			needsMaintenanceSwitch.SetBinding(SwitchCell.OnProperty,"LaneTappedNeedsMaintenance");
			#endregion

			#region create the IP Address Entry
			var ipAddressText = new EntryCell
			{
				Label = "IP Address",
				HorizontalTextAlignment = TextAlignment.End
			};
			ipAddressText.SetBinding(EntryCell.TextProperty, "LaneTappedIPAddress");
			#endregion

			#region Create Image Cell
			var imageCell = new ImageCell();
			imageCell.SetBinding(ImageCell.ImageSourceProperty, "ImageCellIcon");
			#endregion

			#region Create the Icon Toggle Button
			var iconToggleButton = new Button();
			iconToggleButton.SetBinding(Button.CommandProperty, "IconToggleButton");
			iconToggleButton.SetBinding(Button.TextProperty, "ToggleButtonText");
			#endregion

			#region create the TableView
			var tableView = new TableView
			{
				Intent = TableIntent.Settings,
				Root = new TableRoot
				{
					new TableSection{
						isOpenSwitch,
						needsMaintenanceSwitch,
						ipAddressText,
						imageCell
					}
				}
			};
			#endregion

			#region Create StackLayout to Include a Button
			var settingsStack = new StackLayout
			{
				Children ={
					tableView,
					iconToggleButton
				}
			};
			#endregion

			NavigationPage.SetTitleIcon(this,"cogwheel_navigation");

			Title = $"Lane {viewModel.LanesList.IndexOf(viewModel.LaneTapped)+1} Settings";
			Content = settingsStack;
		}
Exemplo n.º 7
0
        /// <summary>
        /// Initializes the component.
        /// </summary>
        /// <param name="tshirt">Tshirt.</param>
        void InitializeComponent(TShirt tshirt)
        {
            var layout = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center
            };

            var image = new Image
            {
                HorizontalOptions = LayoutOptions.Center,
                Source = tshirt.Image
            };

            var label = new Label { HorizontalOptions = LayoutOptions.Center, Text = tshirt.Name };

            var genderCell = new SwitchCell { Text = "Women / Men" };
            genderCell.SetBinding<OrderViewModel>(SwitchCell.OnProperty, vm => vm.IsMen);

            var sizeLabel = new Label { Text = "Size", HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center };
            var sizePicker = new Picker { Title = "Small", WidthRequest = 100.0, HorizontalOptions = LayoutOptions.EndAndExpand, VerticalOptions = LayoutOptions.Center };
            sizePicker.Items.Add("Small");
            sizePicker.Items.Add("Medium");
            sizePicker.Items.Add("Large");
            sizePicker.Items.Add("X-Large");
            sizePicker.SetBinding<OrderViewModel>(Picker.SelectedIndexProperty, vm => vm.SizeIndex);

            var sizeLayout = new StackLayout
            {
                Padding = new Thickness(15, 0),
                Spacing = 0,
                Orientation = StackOrientation.Horizontal,
                Children =
                {
                    sizeLabel,
                    sizePicker
                }
            };

            var sizeCell = new ViewCell
            {
                View = sizeLayout
            };

            var optionSection = new TableSection { Title = "Options" };
            optionSection.Add(genderCell);
            optionSection.Add(sizeCell);

            var tableView = new TableView
            {
                Intent = TableIntent.Form,
                HeightRequest = 300.0,
                Root = new TableRoot
                {
                    optionSection
                }
            };

            var buttonCancel = new Button { HorizontalOptions = LayoutOptions.EndAndExpand, Text = "Cancel" };
            buttonCancel.Clicked += async (sender, e) => await Navigation.PopModalAsync();

            var buttonOrder = new Button { HorizontalOptions = LayoutOptions.StartAndExpand, Text = "Purchase" };
            buttonOrder.SetBinding<OrderViewModel>(Button.CommandProperty, vm => vm.OrderCommand);

            var bottomLayout = new StackLayout
            {
                Spacing = 0,
                Orientation = StackOrientation.Horizontal,
                Children =
                {
                    buttonCancel,
                    new Label
                    {
                        HorizontalOptions = LayoutOptions.CenterAndExpand
                    },
                    buttonOrder
                }
            };

            layout.Children.Add(image);
            layout.Children.Add(label);
            layout.Children.Add(tableView);
            layout.Children.Add(bottomLayout);

            Content = layout;
        }