예제 #1
0
        public InitialPage()
        {
            BindingContext = new InitialPageModel (this.Navigation);

            Title = "Welcome to Peter";

            Label timeLabel = new Label {
                HorizontalOptions = LayoutOptions.Center,
            };
            timeLabel.SetBinding<InitialPageModel> (Label.TextProperty, vm => vm.DrinkingHoursDisplay);

            Slider timeSlider = new Slider (1, 24, 5) {
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            timeSlider.SetBinding<InitialPageModel> (Slider.ValueProperty, vm => vm.DrinkingHours, BindingMode.TwoWay);

            Button pressMe = new Button {
                Text = "Help Peter",
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                FontSize = 60,
                HeightRequest = 200,
                BackgroundColor = Color.Yellow,
            };
            pressMe.SetBinding<InitialPageModel> (Button.CommandProperty, vm => vm.PressMeCommand);

            Content = new StackLayout {
                Children = {
                    timeLabel,
                    timeSlider,
                    pressMe,
                }
            };
        }
예제 #2
0
        public PlayerView()
        {
            var clipTitleLabel = new Label()
            {
                Text = "CLIP TITLE",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                TextColor = Color.White,
                BackgroundColor = Color.Black,
                XAlign = TextAlignment.Center
            };

            var currentStateLabel = new Label() { TextColor = Color.Red, BackgroundColor = Color.Black };

            var playPauseBtn = new Button() { Text = "Pause" };
            var nextBtn = new Button() { Text = "Next" };
            var prevBtn = new Button() { Text = "Prev" };

            var informLayout = new StackLayout
            {
                Spacing = 20,
                Orientation = StackOrientation.Horizontal,
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                IsVisible = false,
                Children = { clipTitleLabel, currentStateLabel, playPauseBtn, nextBtn, prevBtn }
            };

            var button = new Button()
            {
                Text = "Load playlist and play",
                TextColor = Color.White,
                BackgroundColor = Color.Gray,
                VerticalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            button.Clicked += OnButtonClicked;

            var buttonLargeList = new Button()
            {
                Text = "Load large playlist and play",
                TextColor = Color.White,
                BackgroundColor = Color.Gray,
                VerticalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            buttonLargeList.Clicked += OnButtonLargeListClicked;

            var buttonWMV = new Button()
            {
                Text = "Load WMV file and play",
                TextColor = Color.White,
                BackgroundColor = Color.Gray,
                VerticalOptions = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            buttonWMV.Clicked += OnButtonWMVListClicked;

            playerSlider = new Slider()
            {
                VerticalOptions = LayoutOptions.End,
                BackgroundColor = Color.Black,
                Value = 0
            };

            mediaPlayer = new Player();

            playerSlider.BindingContext = mediaPlayer;
            playerSlider.SetBinding(Slider.MaximumProperty, "CurrentVideoDuration", BindingMode.Default, new TimeConverter());
            //playerSlider.SetBinding(Slider.ValueProperty, "Position", BindingMode.TwoWay, new TimeConverter());

            mediaPlayer.CurrentStateChanged += delegate(object sender, StateChangedEventArgs e)
            {
                if (e.NewAction == HyperMediaStateAction.PlayerPlayedToEndOfVideo)
                {
                    mediaPlayer.Next();
                }
                currentStateLabel.Text = mediaPlayer.CurrentPlayerState.ToString();
                playPauseBtn.Text = mediaPlayer.CurrentPlayerState == HyperMediaPlayerState.Playing ? "Pause" : "Play"; ;
            };

            mediaPlayer.PlaylistItemLoaded += delegate(object sender, EventArgs e)
            {
                if (!informLayout.IsVisible) informLayout.IsVisible = true;
                if (mediaPlayer.CurrentItem == null) return;
                clipTitleLabel.Text = mediaPlayer.CurrentItem.Title;
            };

            mediaPlayer.PositionChanged += delegate(object sender, PositionChangedArgs e)
            {
                lockPlayerSliderChangeValueEvent = true;
                playerSlider.Value = e.NewPosition.TotalMilliseconds;
                lockPlayerSliderChangeValueEvent = false;
            };

            /*playerSlider.ValueChanged += delegate(object sender, ValueChangedEventArgs e)
            {
                if (lockPlayerSliderChangeValueEvent) return;
                var delta = e.NewValue - e.OldValue;
                mediaPlayer.SeekBy(new TimeSpan(0, 0, 0, 0, (int)delta));
            };*/

            nextBtn.Clicked += delegate(object sender, EventArgs e)
            {
                mediaPlayer.Next();
            };
            prevBtn.Clicked += delegate(object sender, EventArgs e)
            {
                mediaPlayer.Prev();
            };

            playPauseBtn.Clicked += delegate(object sender, EventArgs e)
            {
                if (mediaPlayer.CurrentPlayerState == HyperMediaPlayerState.Playing)
                    mediaPlayer.Pause();
                else mediaPlayer.Play();
            };

            Content = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children =
                {
                    informLayout,
                    button,
                    buttonLargeList,
                    buttonWMV,
                    playerSlider,
                    mediaPlayer,
                }
            };
            Padding = new Thickness(0, 20, 0, 0);
        }
		public SvgImageSamplePage ()
		{
			_ViewModel = new SvgImageSamplePageViewModel();
			var insetLabel = new Label();
			insetLabel.SetBinding(Label.TextProperty, nameof(SvgImageSamplePageViewModel.SvgInsets), stringFormat: "Stretchable Insets: {0:C2}");
			var resourcePicker = new Picker() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
			};
			foreach (var resourceName in SvgImageSamplePageViewModel.AvailableResourceNames) {
				resourcePicker.Items.Add(resourceName);
			}
			resourcePicker.SetBinding(Picker.SelectedIndexProperty, nameof(SvgImageSamplePageViewModel.SvgResourceIndex), BindingMode.TwoWay);
			var insetSlider = new Slider() {
				Minimum = 0,
				Maximum = 35,
				Value = _ViewModel.AllSidesInset,
			};
			insetSlider.SetBinding(Slider.ValueProperty, nameof(SvgImageSamplePageViewModel.AllSidesInset), BindingMode.TwoWay);
			var slicingSvg = new SvgImage() {
				SvgAssembly = typeof(App).GetTypeInfo().Assembly,
				WidthRequest = 300,
				HeightRequest = 300,
			};
			slicingSvg.SetBinding(SvgImage.SvgStretchableInsetsProperty, nameof(SvgImageSamplePageViewModel.SvgInsets));
			slicingSvg.SetBinding(SvgImage.SvgPathProperty, nameof(SvgImageSamplePageViewModel.SvgResourcePath));
			var svgButton = new Button() {
				WidthRequest = 300,
				HeightRequest = 300,
				BackgroundColor = Color.Transparent,
			};

			// The root page of your application
			Title = "9-Slice SVG Scaling";
			Content = new ScrollView {
				Content = new StackLayout {
					VerticalOptions = LayoutOptions.Start,
					HorizontalOptions = LayoutOptions.Center,
					Children = {
						insetLabel,
						resourcePicker,
						insetSlider,
						new AbsoluteLayout() {
							WidthRequest = 300,
							HeightRequest = 300,
							Children = {
								slicingSvg,
								svgButton,
							},
						},
						new Label () {
							Text = "Using TwinTechsForms.SvgImage",
						},
						new Label () {
							Text = "Proportional Scaling",
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							WidthRequest = 50,
							HeightRequest = 50,
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							WidthRequest = 100,
							HeightRequest = 100,
						},
						new Label () {
							Text = "9-Slice Scaling",
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new ResizableSvgInsets (18),
							WidthRequest = 50,
							HeightRequest = 50,
							HorizontalOptions = LayoutOptions.Start,
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new ResizableSvgInsets (18),
							WidthRequest = 100,
							HeightRequest = 100,
							HorizontalOptions = LayoutOptions.Start,
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new ResizableSvgInsets (18),
							WidthRequest = 300,
							HeightRequest = 300,
							HorizontalOptions = LayoutOptions.Start,
						},
						new Label () {
							Text = "Using TwinTechsForms.NControl.SvgImageView",
						},
						new Label () {
							Text = "Proportional Scaling",
						},
						new SvgImageView() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							WidthRequest = 50,
							HeightRequest = 50,
						},
						new SvgImageView() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							WidthRequest = 100,
							HeightRequest = 100,
						},
						new Label () {
							Text = "9-Slice Scaling",
						},
						new SvgImageView () {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new TwinTechsForms.NControl.ResizableSvgInsets (18),
							WidthRequest = 50,
							HeightRequest = 50,
							HorizontalOptions = LayoutOptions.Start,
						},
						new SvgImageView () {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new TwinTechsForms.NControl.ResizableSvgInsets (18),
							WidthRequest = 100,
							HeightRequest = 100,
							HorizontalOptions = LayoutOptions.Start,
						},
						new SvgImageView () {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new TwinTechsForms.NControl.ResizableSvgInsets (18),
							WidthRequest = 300,
							HeightRequest = 300,
							HorizontalOptions = LayoutOptions.Start,
						},
					},
					BindingContext = _ViewModel,
				},
			};
			svgButton.Clicked += (sender, e) => {
				DisplayAlert("Tapped!", "SVG button tapped!", "OK");
			};
		}
예제 #4
0
		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 Rotation property.
			Label rotationSliderValue = new Label
			{
				VerticalTextAlignment = TextAlignment.Center
			};
			Grid.SetRow(rotationSliderValue, 1);
			Grid.SetColumn(rotationSliderValue, 0);

			Slider rotationSlider = new Slider
			{
				Maximum = 360
			};
			Grid.SetRow(rotationSlider, 1);
			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, 2);
			Grid.SetColumn(anchorxStepperValue, 0);

			Stepper anchorxStepper = new Stepper
			{
				Maximum = 2,
				Minimum = -1,
				Increment = 0.5
			};
			Grid.SetRow(anchorxStepper, 2);
			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, 3);
			Grid.SetColumn(anchoryStepperValue, 0);

			Stepper anchoryStepper = new Stepper
			{
				Maximum = 2,
				Minimum = -1,
				Increment = 0.5
			};
			Grid.SetRow(anchoryStepper, 3);
			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 },
						},
						ColumnDefinitions = 
						{
							new ColumnDefinition { Width = GridLength.Auto },
							new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star)}
						},
						Children = 
						{
							scaleSliderValue,
							scaleSlider,
							rotationSliderValue,
							rotationSlider,
							anchorxStepperValue, 
							anchorxStepper,
							anchoryStepperValue,
							anchoryStepper
						}
					}
				}
			};
		}
        public App() {
            var resourcePicker = new Picker() {
                VerticalOptions = LayoutOptions.CenterAndExpand,
            };
            foreach (var resourceName in TestModel.AvailableResourceNames) {
                resourcePicker.Items.Add(resourceName);
            }
            resourcePicker.SetBinding(Picker.SelectedIndexProperty, nameof(TestModel.SvgResourceIndex), BindingMode.TwoWay);
            var insetSlider = new Slider() {
                Minimum = 0,
                Maximum = 35,
                Value = _ViewModel.AllSidesInset,
            };
            insetSlider.SetBinding(Slider.ValueProperty, nameof(TestModel.AllSidesInset), BindingMode.TwoWay);
            var slicingSvg = new SvgImageView() {
                SvgAssembly = typeof(App).GetTypeInfo().Assembly,
                SvgPath = _ViewModel.SvgResourcePath,
                WidthRequest = 300,
                HeightRequest = 300,
            };
            slicingSvg.SetBinding(SvgImageView.SvgStretchableInsetsProperty, nameof(TestModel.SvgInsets));
            slicingSvg.SetBinding(SvgImageView.SvgPathProperty, nameof(TestModel.SvgResourcePath));

            // The root page of your application
            MainPage = new ContentPage {
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center,
                    Children = {
                        resourcePicker,
                        insetSlider,
                        slicingSvg,
                    },
                    BindingContext = _ViewModel,
                },
            };
        }
예제 #6
0
        public CSPage()
        {
            BindingContext = new SampleViewModel();
            var lblMainText = new Label();
            lblMainText.SetBinding(Label.TextProperty, new Binding("MainText"));
            lblMainText.SetBinding(Label.TextColorProperty, new Binding("LabelsColor"));
            var lblRed = new Label
            {
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof (Label)),
                VerticalOptions = LayoutOptions.Start,
                Text = "Red:"
            };
            var lblGreen = new Label
            {
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                VerticalOptions = LayoutOptions.Start,
                Text = "Green:"
            };
            var lblBlue = new Label
            {
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                VerticalOptions = LayoutOptions.Start,
                Text = "Blue:"
            };
            var sliderRed = new Slider
            {
                Minimum = 0,
                Maximum = 255,
                BackgroundColor = Color.Gray,
                HorizontalOptions = LayoutOptions.Fill,
                HeightRequest = 80,
                VerticalOptions = LayoutOptions.Start
            };
            sliderRed.SetBinding(Slider.ValueProperty,new Binding("Red",BindingMode.TwoWay));

            var sliderGreen = new Slider
            {
                Minimum = 0,
                Maximum = 255,
                BackgroundColor = Color.Gray,
                HorizontalOptions = LayoutOptions.Fill,
                HeightRequest = 80,
                VerticalOptions = LayoutOptions.Start
            };
            sliderGreen.SetBinding(Slider.ValueProperty, new Binding("Green", BindingMode.TwoWay));

            var sliderBlue = new Slider
            {
                Minimum = 0,
                Maximum = 255,
                BackgroundColor = Color.Gray,
                HorizontalOptions = LayoutOptions.Fill,
                HeightRequest = 80,
                VerticalOptions = LayoutOptions.Start
            };
            sliderBlue.SetBinding(Slider.ValueProperty, new Binding("Blue", BindingMode.TwoWay));

            var listado = new ListView();
            listado.SetBinding(ListView.ItemsSourceProperty,"TextosCollection");
            listado.ItemTemplate = new DataTemplate(typeof(TextCell));
            listado.ItemTemplate.SetBinding(TextCell.TextProperty,"AsTexto");
            listado.ItemTemplate.SetBinding(TextCell.TextColorProperty, "ColorTexto");

            Content = new StackLayout
            {
                Children = {
                    lblMainText,lblRed,sliderRed,lblGreen,sliderGreen,lblBlue,sliderBlue,new ScrollView(){Content = listado}
                }
            };
        }
예제 #7
0
		public ChangeLEDColorPage(ParticleDevice device, Dictionary<string, string> variables)
		{
			Title = "RBG LED";
			BackgroundColor = AppColors.BackgroundColor;
			ViewModel = new ChangeLEDColorViewModel(device, variables);
			BindingContext = ViewModel;

			var indicator = new ActivityIndicator { HeightRequest = Device.OnPlatform(50, 30, 50) };
            var colorPreview = new BoxView { HeightRequest = 100 };
			var redSlider = new Slider { StyleId = "redSlider", Minimum = 0, Maximum = 255, Value = 0 };
			var greenSlider = new Slider { StyleId = "greenSlider", Minimum = 0, Maximum = 255, Value = 0 };
			var blueSlider = new Slider { StyleId = "blueSlider", Minimum = 0, Maximum = 255, Value = 0 };
			var push = new StyledButton
			{
				StyleId = "pushRGBvalueButton",
				Text = "PUSH TO PHOTON",
				BackgroundColor = AppColors.Blue,
				CssStyle = "button",
				BorderRadius = 0,
				HeightRequest = AppSettings.ButtonHeight,
				VerticalOptions = LayoutOptions.Fill
			};
			var lightShow = new StyledButton
			{
				StyleId = "startLightShowButton",
				Text = "START A LIGHT SHOW",
				BackgroundColor = AppColors.Green,
				CssStyle = "button",
				BorderRadius = 0,
				HeightRequest = AppSettings.ButtonHeight,
				VerticalOptions = LayoutOptions.End
			};
            var previewLabel = new StyledLabel { CssStyle = "body", Text = "Color Preview:", HorizontalOptions = LayoutOptions.Start };
            var rLabel = new StyledLabel { CssStyle = "body", Text = "R Value", HorizontalOptions = LayoutOptions.Start };
            var gLabel = new StyledLabel { CssStyle = "body", Text = "G Value", HorizontalOptions = LayoutOptions.Start };
            var bLabel = new StyledLabel { CssStyle = "body", Text = "B Value", HorizontalOptions = LayoutOptions.Start };

            Func<RelativeLayout, View, double> layoutAfterPrevious = (p, v) => Device.OnPlatform(
                                                                                    v.Y + v.Height + 5,
                                                                                    v.Y + v.Height + 5,
                                                                                    v.Y + v.Height + 2);

            RelativeLayout relativeLayout = new RelativeLayout();
            relativeLayout.Children.Add(previewLabel,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.Constant(10)
            );
            relativeLayout.Children.Add(colorPreview,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(previewLabel, layoutAfterPrevious),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                heightConstraint: Constraint.Constant(AppSettings.ButtonHeight * 2)
            );
            relativeLayout.Children.Add(rLabel,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(colorPreview, layoutAfterPrevious)
            );
            relativeLayout.Children.Add(redSlider,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(rLabel, layoutAfterPrevious),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2)
            );
            relativeLayout.Children.Add(gLabel,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(redSlider, layoutAfterPrevious)
            );
            relativeLayout.Children.Add(greenSlider,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(gLabel, layoutAfterPrevious),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2)
            );
            relativeLayout.Children.Add(bLabel,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(greenSlider, layoutAfterPrevious)
            );
            relativeLayout.Children.Add(blueSlider,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(bLabel, layoutAfterPrevious),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2)
            );
            relativeLayout.Children.Add(indicator,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(blueSlider, layoutAfterPrevious),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                heightConstraint: Constraint.Constant(Device.OnPlatform(50,50,25))
            );
            relativeLayout.Children.Add(lightShow,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                heightConstraint: Constraint.Constant(AppSettings.ButtonHeight)
            );
            relativeLayout.Children.Add(push,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(lightShow, (p, v) => v.Y - AppSettings.ButtonHeight - 10),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                heightConstraint: Constraint.Constant(AppSettings.ButtonHeight)
            );
            


   //         StackLayout layout = new StackLayout
			//{
			//	VerticalOptions = LayoutOptions.CenterAndExpand,
			//	Padding = new Thickness(AppSettings.Margin, 10, AppSettings.Margin, AppSettings.Margin),
			//	Spacing = 10,
			//	Children = {
			//		new StyledLabel { CssStyle = "body", Text = "Color Preview:", HorizontalOptions = LayoutOptions.Start },
			//		colorPreview,
			//		new StyledLabel { CssStyle = "body", Text = "R Value", HorizontalOptions = LayoutOptions.Start },
			//		redSlider,
			//		new StyledLabel { CssStyle = "body", Text = "G Value", HorizontalOptions = LayoutOptions.Start },
			//		greenSlider,
			//		new StyledLabel { CssStyle = "body", Text = "B Value", HorizontalOptions = LayoutOptions.Start },
			//		blueSlider,
			//		indicator,
			//		push,
			//		lightShow
			//	}
			//};

			if (Device.OS == TargetPlatform.iOS)
			{
				push.FontFamily = "SegoeUI-Light";
				push.FontSize = 16;
				push.TextColor = Color.FromHex("#ffffff");

				lightShow.FontFamily = "SegoeUI-Light";
				lightShow.FontSize = 16;
				lightShow.TextColor = Color.FromHex("#ffffff");
			}

            var off = new ToolbarItem { Text = "LEDs Off" };

            Content = relativeLayout;


            indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
            if (Device.OS != TargetPlatform.iOS && Device.OS != TargetPlatform.Android)
                indicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");

            redSlider.SetBinding(Slider.ValueProperty, "R", BindingMode.TwoWay);
			greenSlider.SetBinding(Slider.ValueProperty, "G", BindingMode.TwoWay);
			blueSlider.SetBinding(Slider.ValueProperty, "B", BindingMode.TwoWay);
			colorPreview.SetBinding(BoxView.BackgroundColorProperty, "ColorBoxColor");
			push.SetBinding(Button.CommandProperty, "PushColorCommand");
			lightShow.SetBinding(Button.CommandProperty, "LightShowCommand");
			off.SetBinding(ToolbarItem.CommandProperty, "LedsOffCommand");

			ToolbarItems.Add(off);
		}
		public RotationYDemoPage ()
		{
			this.Title = "RotationY";

			// Label to be transformed.
			Label label = new Label {
				Text = "ROTATIONY",
				FontSize = 50,
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

			// Label and Slider for RotationY property.
			Label rotationSliderValue = new Label {
				VerticalTextAlignment = 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, "RotationY = {0:F0}\u00B0"));

			rotationSlider.BindingContext = label;
			rotationSlider.SetBinding (Slider.ValueProperty,
				new Binding ("RotationY", 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 = GridLength.Auto },
							new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }
						},
						Children = {
							rotationSliderValue,
							rotationSlider,
							anchorxStepperValue, 
							anchorxStepper,
							anchoryStepperValue,
							anchoryStepper
						}
					}
				}
			};

		}
예제 #9
0
        public XSquaredCode()
        {
            dg = new DataGrid()
            {
                BackgroundColor = Xamarin.Forms.Color.Black,
                RowHeight = 80,

                Columns = new List<Column> {
                    new Column {
                        Width = 80,
                        HeaderView = new Label {
                            Text = "X",
                            BackgroundColor = Color.Gray,
                            XAlign = TextAlignment.Center,
                            YAlign = TextAlignment.Center,
                        },
                        Template = new DataTemplate (() => {
                            var v = new Label {
                                BackgroundColor = Color.White,
                                TextColor = Color.Black,
                                XAlign = TextAlignment.Center,
                                YAlign = TextAlignment.Center,
                            };
                            v.SetBinding (Label.TextProperty, "X");
                            return v;
                        }),
                    },
                    new Column {
                        Width = 80,
                        HeaderView = new Label {
                            Text = "X^2",
                            BackgroundColor = Color.Gray,
                            XAlign = TextAlignment.Center,
                            YAlign = TextAlignment.Center,
                        },
                        Template = new DataTemplate (() => {
                            var v = new Label {
                                BackgroundColor = Color.White,
                                TextColor = Color.Black,
                                XAlign = TextAlignment.Center,
                                YAlign = TextAlignment.Center,
                            };
                            v.SetBinding (Label.TextProperty, "XSquared");
                            return v;
                        }),
                    },
                    new Column {
                        Width = 120,
                        HeaderView = new Label {
                            Text = "Slider",
                            BackgroundColor = Color.Gray,
                            XAlign = TextAlignment.Center,
                            YAlign = TextAlignment.Center,
                        },
                        Template = new DataTemplate (() => {
                            var s = new Slider
                            {

                                VerticalOptions = LayoutOptions.Center,
                                BackgroundColor = Color.White,
                                Minimum = -20,
                                Maximum = 20,
                            };
                            //The slider is wrapped in a ContentView, because Android sliders
                            //do not cope well with having their height set by the
                            //grid control.
                            var v = new ContentView
                            {
                                BackgroundColor = Color.White,
                                Content = s
                            };
                            s.SetBinding (Slider.ValueProperty, "X", BindingMode.TwoWay);
                            return v;
                        }),
                    },
                }
            };

            this.Content = dg;
        }
예제 #10
0
        public App() {
            _ViewModel = new TestModel();
            var insetLabel = new Label();
            insetLabel.SetBinding(Label.TextProperty, nameof(TestModel.SvgInsets), stringFormat: "Stretchable Insets: {0:C2}");
            var resourcePicker = new Picker() {
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            foreach (var resourceName in TestModel.AvailableResourceNames) {
                resourcePicker.Items.Add(resourceName);
            }
            resourcePicker.SetBinding(Picker.SelectedIndexProperty, nameof(TestModel.SvgResourceIndex), BindingMode.TwoWay);
            var insetSlider = new Slider() {
                Minimum = 0,
                Maximum = 35,
                Value = _ViewModel.AllSidesInset,
            };
            insetSlider.SetBinding(Slider.ValueProperty, nameof(TestModel.AllSidesInset), BindingMode.TwoWay);
            var slicingSvg = new SvgImage() {
                SvgAssembly = typeof(App).GetTypeInfo().Assembly,
                WidthRequest = 300,
                HeightRequest = 300,
            };
            slicingSvg.SetBinding(SvgImage.SvgStretchableInsetsProperty, nameof(TestModel.SvgInsets));
            slicingSvg.SetBinding(SvgImage.SvgPathProperty, nameof(TestModel.SvgResourcePath));
            var svgButton = new Button() {
                WidthRequest = 300,
                HeightRequest = 300,
            };

            // The root page of your application
            MainPage = new NavigationPage (new ContentPage {
                Title = "9-Slice SVG Scaling",
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Start,
                    HorizontalOptions = LayoutOptions.Center,
                    Children = {
                        insetLabel,
                        resourcePicker,
                        insetSlider,
                        new AbsoluteLayout() {
                            WidthRequest = 300,
                            HeightRequest = 300,
                            Children = {
                                slicingSvg,
                                svgButton,
                            },
                        },
                    },
                    BindingContext = _ViewModel,
                },
            });
            svgButton.Clicked += (sender, e) => {
                MainPage.DisplayAlert("Tapped!", "SVG button tapped!", "OK");
            };
        }
예제 #11
0
        public Escala()
        {
            this.Title = "Escala";

            // Etiqueta que vamos a transformar
            var Etiqueta = new Label
            {
				Text = "Ricky!!",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            // Creamos un Label y un Slider con el que transformaremos nuestra etiqueta
            Label Valordeescala = new Label
            {
                YAlign = TextAlignment.Center
            };
            //seleccionamos la posicion de la etiqueta
            Grid.SetRow(Valordeescala, 0);
            Grid.SetColumn(Valordeescala, 0);

            //Creamos un slider con el que le daremos la escala a la etiqueta
            Slider SliderEscala = new Slider
            {
                Maximum = 10
            };
            //seleccionamos la posicion del slider
            Grid.SetRow(SliderEscala, 0);
            Grid.SetColumn(SliderEscala, 1);

            // Creamos nuestros Binding para el slider y la etiqueta que escalaremos 
            Valordeescala.BindingContext = SliderEscala;
            Valordeescala.SetBinding(Label.TextProperty,
                new Binding("Value", BindingMode.OneWay,
					null, null, "Escala = {0:F1}"));

            SliderEscala.BindingContext = Etiqueta;
            SliderEscala.SetBinding(Slider.ValueProperty,
				new Binding("Scale", BindingMode.TwoWay));


            //Montamos la pagina.
            this.Content = new StackLayout
            {
                Children =
                {
                    Etiqueta,
                    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 = 
                        {
                            Valordeescala,
                            SliderEscala,
                           
                        }
                    }
                }
            };
        }
예제 #12
0
        public BubblePopupTestPage()
        {
            BackgroundColor = Color.White;
            Padding = new Thickness(20,Device.OnPlatform(20,0,0),20,20);

            var shadowToggle = new Switch ();
            shadowToggle.SetBinding (Switch.IsToggledProperty, "HasShadow");
            shadowToggle.BindingContext = this;

            var shadowInvertedToggle = new Switch ();
            shadowInvertedToggle.SetBinding (Switch.IsToggledProperty, "ShadowInverted");
            shadowInvertedToggle.BindingContext = this;

            var cornerRadiusSlider = new Slider {
                Maximum = 40,
                Minimum = 0,
                HeightRequest = 20,
            };
            cornerRadiusSlider.SetBinding (Slider.ValueProperty, "CornerRadius");
            cornerRadiusSlider.BindingContext = this;

            var pointerLengthSlider = new Slider {
                Maximum = 40,
                Minimum = 0,
                HeightRequest = 20,
            };
            pointerLengthSlider.SetBinding (Slider.ValueProperty, "PointerLength");
            pointerLengthSlider.BindingContext = this;

            var pointerTipRadiusSlider = new Slider {
                Maximum = 20,
                Minimum = 0,
                HeightRequest = 20,
            };
            pointerTipRadiusSlider.SetBinding (Slider.ValueProperty, "PointerTipRadius");
            pointerTipRadiusSlider.BindingContext = this;

            var paddingSlider = new Slider {
                Maximum = 100,
                Minimum = 0,
                HeightRequest = 20,
            };
            paddingSlider.SetBinding (Slider.ValueProperty, "PUDPadding");
            paddingSlider.BindingContext = this;

            var pointerCornerRadiusSlider = new Slider {
                Maximum = 20,
                Minimum = 0,
                HeightRequest = 20,
            };
            pointerCornerRadiusSlider.SetBinding (Slider.ValueProperty, "PointerCornerRadius");
            pointerCornerRadiusSlider.BindingContext = this;

            var leftSeg = new Forms9Patch.Segment {
                Text = "⬅︎",
                IsSelected = true,
            };
            leftSeg.Tapped += (sender, e) => _lastChanged = leftSeg.VisualElement;
            var upSeg = new Forms9Patch.Segment {
                Text = "⬆︎",
            };
            upSeg.Tapped += (sender, e) => _lastChanged = upSeg.VisualElement;
            var rightSeg = new Forms9Patch.Segment {
                Text = "➡︎",
            };
            rightSeg.Tapped += (sender, e) => _lastChanged = rightSeg.VisualElement;
            var downSeg = new Forms9Patch.Segment {
                Text = "⬇︎",
            };
            downSeg.Tapped += (sender, e) => _lastChanged = downSeg.VisualElement;

            PointerDirection = Forms9Patch.PointerDirection.Left;
            var directionSegmentControl = new Forms9Patch.MaterialSegmentedControl {
                Segments = { leftSeg, upSeg, rightSeg, downSeg, },
                GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect,
            };
            directionSegmentControl.SegmentTapped += (sender,e) => {
                var dir = Forms9Patch.PointerDirection.None;
                dir |= (leftSeg.IsSelected ? Forms9Patch.PointerDirection.Left : Forms9Patch.PointerDirection.None);
                dir |= (rightSeg.IsSelected ? Forms9Patch.PointerDirection.Right : Forms9Patch.PointerDirection.None);
                dir |= (upSeg.IsSelected ? Forms9Patch.PointerDirection.Up : Forms9Patch.PointerDirection.None);
                dir |= (downSeg.IsSelected ? Forms9Patch.PointerDirection.Down : Forms9Patch.PointerDirection.None);
                PointerDirection = dir;
                System.Diagnostics.Debug.WriteLine("Direction changed");
            };

            var bubbleLabel = new Label {
                Text = "Forms9Patch.BubblePopup",
                TextColor = Color.Black,
                //BackgroundColor = Color.Green,
            };
            var bubbleButton = new Forms9Patch.MaterialButton {
                Text = "Close",
                //BackgroundColor = Color.Blue,
                OutlineColor = Color.Blue,
                FontColor = Color.Blue,
            };
            //bubbleLabel.SetBinding (Label.TextProperty, "CornerRadius");
            bubbleLabel.BindingContext = this;

            var bubble = new Forms9Patch.BubblePopup {
                //BackgroundColor = Color.Green,
                //OutlineColor = Color.Black,
                //OutlineWidth = 1,
                PointerCornerRadius = 0,
                Content = new StackLayout {
                    Children = {
                        //bubbleLabel,
                        new Label { Text = "Pointer Length:", FontSize=10, },
                        pointerLengthSlider,
                        new Label { Text = "Pointer Tip Radius:", FontSize=10, },
                        pointerTipRadiusSlider,
                        new Label { Text = "Corner Radius:" , FontSize=10, },
                        cornerRadiusSlider,
                        new Label { Text = "Pointer Corner Radius:" , FontSize=10, },
                        pointerCornerRadiusSlider,
                        bubbleButton,
                    }
                },
            };
            bubble.SetBinding (Forms9Patch.BubblePopup.OutlineRadiusProperty, "CornerRadius");
            bubble.SetBinding (Forms9Patch.BubblePopup.PointerLengthProperty, "PointerLength");
            bubble.SetBinding (Forms9Patch.BubblePopup.PointerTipRadiusProperty, "PointerTipRadius");
            bubble.SetBinding (Forms9Patch.BubblePopup.PaddingProperty, "PUPadding");
            bubble.SetBinding (Forms9Patch.BubblePopup.HasShadowProperty, "HasShadow");
            bubble.SetBinding (Forms9Patch.BubblePopup.ShadowInvertedProperty, "ShadowInverted");
            bubble.SetBinding (Forms9Patch.BubblePopup.PointerDirectionProperty, "PointerDirection");
            bubble.SetBinding (Forms9Patch.BubblePopup.PointerCornerRadiusProperty, "PointerCornerRadius");
            bubble.BindingContext = this;

            bubbleButton.Tapped += (sender, e) => bubble.IsVisible = false;

            var showButton = new Forms9Patch.MaterialButton {
                Text = "Show BubblePopup",
                OutlineColor = Color.Blue,
                FontColor = Color.Blue,
            };
            showButton.Tapped += (object sender, EventArgs e) => {
                bubble.Target = _lastChanged;
                bubble.IsVisible = true;
            };

            _lastChanged = leftSeg.VisualElement;

            Content = new StackLayout {
                Children = {
                    new StackLayout {
                        Orientation = StackOrientation.Horizontal,
                        Children = {
                            new StackLayout {
                                Children = {
                                    new Label { Text = "Has Shadow", FontSize=10, },
                                    shadowToggle,
                                },
                                HorizontalOptions = LayoutOptions.StartAndExpand,
                            },
                            new StackLayout {
                                Children = {
                                    new Label { Text = "Inset Shadow", FontSize=10, },
                                    shadowInvertedToggle,
                                },
                                HorizontalOptions = LayoutOptions.EndAndExpand,
                            }
                        }
                    },
                    new Label { Text = "Padding:", FontSize=10, },
                    paddingSlider,
                    new Label { Text = "Pointer Direction", FontSize=10, },
                    directionSegmentControl,
                    showButton,
                    new Label { Text = "Arrows choose the BubblePopup's allowed pointer direction.  Bubble's pointer will point at the last selected arrow-segment-button." },
                }
            };
        }
예제 #13
0
        public Rotacion()
        {
            //Agregamos nuestro titulo a nuestra pagina
            this.Title = "Rotacion";

            // Etiqueta que vamos a transformar
            Label Etiqueta = new Label
            {
				Text = "Ricky!!",
                Font = Font.SystemFontOfSize(50),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            //  Creamos un Label y un Slider con el que transformaremos nuestra etiqueta
            Label Valorderotacion = new Label
            {
                YAlign = TextAlignment.Center
            };
            //seleccionamos la posicion de la etiqueta
            Grid.SetRow(Valorderotacion, 0);
            Grid.SetColumn(Valorderotacion, 0);

            //Creamos nuestro slider 
            Slider SliderRotacion = new Slider
            {
                //la rotacion maxima de la etiqueta 
                Maximum = 360
            };
            //seleccionamos la posicion del slider
            Grid.SetRow(SliderRotacion, 0);
            Grid.SetColumn(SliderRotacion, 1);

            // Creamos nuestros Binding para el slider y la etiqueta que rotaremos
            Valorderotacion.BindingContext = SliderRotacion;
            Valorderotacion.SetBinding(Label.TextProperty,
                new Binding("Value", BindingMode.OneWay,
                            null, null, "Rotacion = {0:F0}\u00B0"));

            SliderRotacion.BindingContext = Etiqueta;
            SliderRotacion.SetBinding(Slider.ValueProperty,
				new Binding("Rotation", BindingMode.TwoWay));


            //Montamos la pagina.
            this.Content = new StackLayout
            {
                Children =
                {
                    Etiqueta,
                    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 = 
                        {
                            Valorderotacion,
                            SliderRotacion
                        
                        }
                    }
                }
            };
        }
        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}"));
        }