当前位置: 首页>>代码示例>>C#>>正文


C# StackLayout类代码示例

本文整理汇总了C#中StackLayout的典型用法代码示例。如果您正苦于以下问题:C# StackLayout类的具体用法?C# StackLayout怎么用?C# StackLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StackLayout类属于命名空间,在下文中一共展示了StackLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MenuForm

        /// <summary>
        /// Creates a new menu form.
        /// </summary>
        /// <param name="title">Window title.</param>
        /// <param name="itemNames">Item names.</param>
        /// <param name="actions">Actions.</param>
        public MenuForm(string title, string[] itemNames, Action[] actions)
        {
            Title = title;
            SelectedIndex = -1;

            if (itemNames == null || actions == null)
                return;
            if (itemNames.Length != actions.Length)
                return;

            var stackLayout = new StackLayout {Orientation = Orientation.Vertical, HorizontalContentAlignment = HorizontalAlignment.Stretch };

            for (int i = 0; i < itemNames.Length; i++)
            {
                var idx = i;

                var button = new Button { Text = itemNames[idx], Size = new Size(240, 60) }; 
                button.Click += (s, e) =>
                {
                    actions[idx]();
                    SelectedIndex = idx;
                    this.Close();
                };

                stackLayout.Items.Add(new StackLayoutItem(button, true));
            }

            Content = stackLayout;
            Size = new Size(-1, -1);
        }
开发者ID:gitter-badger,项目名称:dot-imaging,代码行数:36,代码来源:MenuForm.cs

示例2: Init

        protected override void Init ()
        {
            var picker = new Picker () { Items = {"Leonardo", "Donatello", "Raphael", "Michaelangelo" } };
            var label = new Label () {Text = "This test is successful if the picker below spans the width of the screen. If the picker is just a sliver on the left edge of the screen, this test has failed." };

            Content = new StackLayout () { Children = {label, picker}};
        }
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:7,代码来源:Bugzilla36014.cs

示例3: ChildPage

			public ChildPage(int pageNumber)
			{
				var layout = new StackLayout();
				var MyLabel = new Label {
					VerticalOptions = LayoutOptions.Center,
					HorizontalOptions = LayoutOptions.Center,
					FontSize = 21,
					TextColor = Color.White,
					Text = $"This is page {pageNumber}"
				};
				var TestBtn = new Button {
					Text = "Go to Page 2",
					IsEnabled = false,
					BackgroundColor = Color.White
				};

				if (pageNumber != 2)
				{
					TestBtn.IsEnabled = true;
					TestBtn.Clicked += TestBtn_Clicked;
				}

				layout.Children.Add(MyLabel);
				layout.Children.Add(TestBtn);
				Content = layout;
			}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:26,代码来源:Bugzilla39458.cs

示例4: ComplexListView

		public ComplexListView()
		{
			Performance.Clear();

			var showPerf = new Button { Text = "Performance" };
			showPerf.Clicked += (sender, args) => {
				Performance.DumpStats();
				Performance.Clear();
			};

			Content = new StackLayout {
				Orientation = StackOrientation.Vertical,
				Children = {
					showPerf,
					new ListView {
						ItemTemplate = new DataTemplate (typeof (ComplexViewCell)),
						ItemsSource =
							new[] {
								"a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
								"b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c"
							}
					}
				}
			};
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:25,代码来源:ComplexListView.cs

示例5: PixelOffsetTransforms

		public PixelOffsetTransforms()
		{
			HorizontalContentAlignment = HorizontalAlignment.Stretch;
			Spacing = 5;

			var canvas = new TestCanvas();

			var offsetMode = new EnumDropDown<PixelOffsetMode>();
			offsetMode.SelectedValueBinding.Bind(canvas, c => c.PixelOffsetMode);

			var testDropDown = new DropDown();
			testDropDown.ItemTextBinding = Binding.Property((TestInfo t) => t.Name);
			testDropDown.SelectedValueBinding.Cast<TestInfo>().Bind(canvas, c => c.Test);
			testDropDown.DataStore = tests;
			testDropDown.SelectedIndex = 0;

			var options = new StackLayout
			{
				Orientation = Orientation.Horizontal,
				VerticalContentAlignment = VerticalAlignment.Center,
				Spacing = 5,
				Padding = new Padding(10),
				Items =
				{
					"PixelOffsetMode",
					offsetMode,
					"Test",
					testDropDown
				}
			};

			Items.Add(options);
			Items.Add(new StackLayoutItem(canvas, true));
		}
开发者ID:mhusen,项目名称:Eto,代码行数:34,代码来源:PixelOffsetTransforms.cs

示例6: Init

		protected override void Init ()
		{
			Label header = new Label {
				Text = "Search Bar",
				FontAttributes = FontAttributes.Bold,
				FontSize = 50,
				HorizontalOptions = LayoutOptions.Center
			};

			SearchBar searchBar = new SearchBar {
				Placeholder = "Enter anything",
				CancelButtonColor = Color.Red
			};

			Label reproSteps = new Label {
				Text =
					"Tap on the search bar and enter some text. The 'Cancel' button should appear. If the 'Cancel' button is not red, this is broken.",
				HorizontalOptions = LayoutOptions.Center
			};

			Content = new StackLayout {
				Children = {
					header,
					searchBar,
					reproSteps
				}
			};
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:28,代码来源:Bugzilla33890.cs

示例7: Init

		protected override void Init ()
		{
			var rootGrid = new Grid {
				RowDefinitions = new RowDefinitionCollection
														  {
															 new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
															 new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) },
														 },
			};


			_mainContent = new ContentView { Content = new ScrollView { Content = new Label { Text = Description } } };
			rootGrid.AddChild (_mainContent, 0, 0);


			var buttons = new StackLayout { Orientation = StackOrientation.Horizontal };

			var button1A = new Button { Text = "View 1A" };
			button1A.Clicked += (sender, args) => ShowView (_view1A);
			buttons.Children.Add (button1A);

			var button1B = new Button { Text = "View 1B" };
			button1B.Clicked += (sender, args) => ShowView (_view1B);
			buttons.Children.Add (button1B);

			var button2 = new Button { Text = "View 2" };
			button2.Clicked += (sender, args) => ShowView (_view2);
			buttons.Children.Add (button2);

			rootGrid.AddChild (buttons, 0, 1);


			Content = rootGrid;
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:34,代码来源:Bugzilla27642.cs

示例8: Init

		protected override void Init ()
		{
			var listView = new ListView ();

			var selection = new Selection ();
			listView.SetBinding (ListView.ItemsSourceProperty, "Items");

			listView.ItemTemplate = new DataTemplate (() => {
				var cell = new SwitchCell ();
				cell.SetBinding (SwitchCell.TextProperty, "Name");
				cell.SetBinding (SwitchCell.OnProperty, "IsSelected", BindingMode.TwoWay);
				return cell;
			});

			var instructions = new Label {
				FontSize = 16,
				Text =
					"The label at the bottom should equal the number of switches which are in the 'on' position. Flip some of the switches. If the number at the bottom does not equal the number of 'on' switches, the test has failed."
			};

			var label = new Label { FontSize = 24 };
			label.SetBinding (Label.TextProperty, "SelectedCount");

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.Fill,
				Children = {
					instructions,
					listView,
					label
				}
			};

			BindingContext = selection;
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:34,代码来源:Bugzilla31964.cs

示例9: Init

		protected override void Init ()
		{
			Content = new StackLayout {
				VerticalOptions = LayoutOptions.Center,
				Children = {
					new Label {
#pragma warning disable 618
						XAlign = TextAlignment.Center,
#pragma warning restore 618
						Text = "Welcome to Xamarin Forms!"
					},
					new Button {
						Text = "Without Params (Works)",
						AutomationId = "btnOpenUri1",
						Command = new Command (() => Device.OpenUri (new Uri ("http://www.bing.com")))
					},
					new Button {
						Text = "With encoded Params (Breaks)",
						AutomationId = "btnOpenUri2",
						Command = new Command (() => Device.OpenUri (new Uri ("http://www.bing.com/search?q=xamarin%20bombs%20on%20this")))
					},
					new Button {
						Text = "With decoded Params (Breaks)",
						AutomationId = "btnOpenUri3",
						Command = new Command (() => Device.OpenUri (new Uri ("http://www.bing.com/search?q=xamarin bombs on this")))
					}
				}
			};
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:29,代码来源:Bugzilla29247.cs

示例10: Init

		protected override void Init ()
		{
			var generatedImage = new Image { Aspect = Aspect.AspectFit };

			var btn = new Button { Text="generate" };

			btn.Clicked += (sender, e) => {
				var source =  GenerateBmp (60, 60, Color.Red);
				generatedImage.Source = source;

			};

			Content = new StackLayout {
				Children = {
						btn,
#pragma warning disable 618
                    new Label {Text = "GeneratedImage", Font=Font.BoldSystemFontOfSize(NamedSize.Medium)},
#pragma warning restore 618
                    generatedImage
                },
				Padding = new Thickness (0, 20, 0, 0),
				VerticalOptions = LayoutOptions.StartAndExpand,
				HorizontalOptions = LayoutOptions.CenterAndExpand
			};
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:25,代码来源:Bugzilla31029.cs

示例11: Init

		protected override void Init()
		{
			var button = new Button
			{
				AutomationId = "crashButton",
				Text = "Start Test"
			};

			var success = new Label { Text = "Success", IsVisible = false, AutomationId = "successLabel" };

			var instructions = new Label { Text = "Click the Start Test button. " };

			Content = new StackLayout
			{
				HorizontalOptions = LayoutOptions.Fill,
				VerticalOptions = LayoutOptions.Fill,
				Children = { instructions, success, button }
			};

			button.Clicked += async (sender, args) =>
			{
				await Task.WhenAll(GenerateTasks());
				success.IsVisible = true;
			};
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:25,代码来源:IsInvokeRequiredRaceCondition.cs

示例12: PreviewEditorView

		public PreviewEditorView(Control editor, Func<string> getCode)
		{
			Editor = editor;
			this.getCode = getCode;

			Orientation = Orientation.Vertical;
			FixedPanel = SplitterFixedPanel.None;
			RelativePosition = 0.4;

			previewPanel = new Panel();
			errorPanel = new Panel { Padding = new Padding(5), Visible = false, BackgroundColor = new Color(Colors.Red, .4f) };

			Panel1 = new StackLayout
			{
				HorizontalContentAlignment = HorizontalAlignment.Stretch,
				Items =
				{
					new StackLayoutItem(previewPanel, expand: true),
					errorPanel
				}
			};
			Panel2 = editor;

			timer = new UITimer { Interval = RefreshTime };
			timer.Elapsed += Timer_Elapsed;
		}
开发者ID:mhusen,项目名称:Eto,代码行数:26,代码来源:PreviewEditorView.cs

示例13: Issue2292

		public Issue2292 ()
		{
			var datePicker = new DatePicker ();
			var datePickerBtn = new Button {
				Text = "Click me to call .Focus on DatePicker"
			};

			datePickerBtn.Clicked += (sender, args) => {
				datePicker.Focus ();
			};

			var datePickerBtn2 = new Button {
				Text = "Click me to call .Unfocus on DatePicker"
			};

			datePickerBtn2.Clicked += (sender, args) => {
				datePicker.Unfocus ();
			};

			Content = new StackLayout {
				Children = {
					datePickerBtn, 
					datePickerBtn2, 
					datePicker,
				}
			};
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:27,代码来源:Issue2292.cs

示例14: Init

		protected override void Init ()
		{
			var instructions = new Label { FontSize = 24, Text = "The first ListView below should have a Xamarin logo visible in it. The second should have a pink image with white writing. If either image is not displayed, this test has failed." };

			ImageSource remoteSource =
				ImageSource.FromUri (new Uri ("https://xamarin.com/content/images/pages/branding/assets/xamagon.png"));
			ImageSource localSource = ImageSource.FromFile ("oasis.jpg");

			var remoteImage = new Image { Source = remoteSource, BackgroundColor = Color.Red };
			var localImage = new Image { Source = localSource, BackgroundColor = Color.Red };

			var listViewRemoteImage = new ListView {
				BackgroundColor = Color.Green,
				ItemTemplate = new DataTemplate (() => new TestCellGridImage (remoteImage)),
				ItemsSource = new List<string> { "1" }
			};

			var listViewLocalImage = new ListView {
				BackgroundColor = Color.Green,
				ItemTemplate = new DataTemplate (() => new TestCellGridImage (localImage)),
				ItemsSource = new List<string> { "1" }
			};

			Content = new StackLayout {
				Children = {
					instructions,
					listViewRemoteImage,
					listViewLocalImage
				}
			};
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:31,代码来源:DataTemplateGridImageTest.cs

示例15: StackLayoutGallery

		public StackLayoutGallery ()
		{
			Device.OnPlatform (iOS: () => {
				if (Device.Idiom == TargetIdiom.Tablet) {
					Padding = new Thickness (0, 0, 0, 60);
				}
			});

			var stack = new StackLayout { Orientation = StackOrientation.Vertical };
			Button b1 = new Button { Text = "Boring", HeightRequest = 500, MinimumHeightRequest = 50 };
			Button b2 = new Button {
				Text = "Exciting!",
				VerticalOptions = LayoutOptions.FillAndExpand,
				HorizontalOptions = LayoutOptions.CenterAndExpand
			};
			Button b3 = new Button { Text = "Amazing!", VerticalOptions = LayoutOptions.FillAndExpand };
			Button b4 = new Button { Text = "Meh", HeightRequest = 400, MinimumHeightRequest = 50 };
			b1.Clicked += (sender, e) => {
				b1.Text = "clicked1";
			};
			b2.Clicked += (sender, e) => {
				b2.Text = "clicked2";
			};
			b3.Clicked += (sender, e) => {
				b3.Text = "clicked3";
			};
			b4.Clicked += (sender, e) => {
				b4.Text = "clicked4";
			};
			stack.Children.Add (b1);
			stack.Children.Add (b2);
			stack.Children.Add (b3);
			stack.Children.Add (b4);
			Content = stack;
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:35,代码来源:StackLayoutGallery.cs


注:本文中的StackLayout类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。