• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# StackLayout类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Init

		protected override void Init ()
		{
			var instructions = new Label {
				Text =
					"The label in the red box below should be centered horizontally and vertically. If it's not, this test has failed."
			};


			var label = new Label {
				BackgroundColor = Color.Red,
				TextColor = Color.White,
				HorizontalTextAlignment = TextAlignment.Center,
				VerticalTextAlignment = TextAlignment.Center,
				HeightRequest = 200,
				HorizontalOptions = LayoutOptions.Fill,
				Text = "Should be centered horizontally and vertically"
			};


			Content = new StackLayout {
				HorizontalOptions = LayoutOptions.Fill,
				VerticalOptions = LayoutOptions.Fill,
				Children = {
					instructions,
					label
				}
			};
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:28,代码来源:Bugzilla35490.cs


示例17: CreateGui

		public MonoGameGuiManager CreateGui( )
		{
			
			var textureAtlas = new TextureAtlas("Atlas1");
            var upRegion = textureAtlas.AddRegion("cog", 48, 0, 47, 47);
            var cogRegion = textureAtlas.AddRegion("up", 0, 0, 47, 47);

			_gui = new MonoGameGuiManager(_game.GraphicsDevice, _game.Content);
            _gui.LoadContent(new GuiContent(textureAtlas, "ExampleFont.fnt", "ExampleFont_0"));
			
			var screen = new Screen(800, 480);
			var dockLayout = new DockLayout();
			var gridLayout = new GridLayout(1, 2);
			var leftStackLayout = new StackLayout() { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Bottom };
			var loadRubeFileBtn = CreateButton(cogRegion);
			var dumpRubeFileBtn = CreateButton(upRegion);
						
			dockLayout.Items.Add(new DockItem(gridLayout, DockStyle.Bottom));

            dumpRubeFileBtn.Tag = "dump";
			loadRubeFileBtn.Tag = "load";
			leftStackLayout.Items.Add(loadRubeFileBtn);
			leftStackLayout.Items.Add(dumpRubeFileBtn);
			
			gridLayout.Items.Add(new GridItem(leftStackLayout, 0, 0));
			
			
			screen.Items.Add(dockLayout);
			_gui.Screen = screen;

			return _gui;
		}
开发者ID:netonjm,项目名称:Rube.Net,代码行数:32,代码来源:GUIDemo.cs


示例18: Issue1742

		public Issue1742 ()
		{
			 var listView = new ListView
            {
                RowHeight = 40
            };
            var invisibleButton = new Button
            {
                IsVisible = false,
                Text = "INVISIBLE button"
            };
            var visibleButton = new Button
            {
                IsVisible = true,
                Text = "Visible button"
            };

            invisibleButton.Clicked += Button_Clicked;
            visibleButton.Clicked += Button_Clicked;
            listView.ItemTapped += ListView_ItemTapped;

            listView.ItemsSource = new string[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = { listView, visibleButton, invisibleButton }
			};

		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:29,代码来源:Issue1742.cs


示例19: Init

 protected override void Init()
 {
     var picker = new Picker
     {
         IsEnabled = false
     };
     picker.Items.Add("item");
     picker.Items.Add("item 2");
     
     Content = new StackLayout
     {
         Children =
         {
             picker,
             new Button
             {
                 Command = new Command(() =>
                 {
                     if (picker.IsEnabled)
                         picker.IsEnabled = false;
                     else
                         picker.IsEnabled = true;
                 }),
                 Text = "Enable/Disable Picker"
             }
         }
     };
 }
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:28,代码来源:Bugzilla36479.cs


示例20: Init

		protected override void Init()
		{
			var stack = new StackLayout();

			map1 = new Maps.Map
			{
				IsShowingUser = false,
				WidthRequest = 320,
				HeightRequest = 200
			};

			map2 = new Maps.Map
			{
				IsShowingUser = false,
				WidthRequest = 320,
				HeightRequest = 200
			};


			var btn = new Button { Text = "Show" };
			btn.Clicked += (sender, e) =>
			{
				map2.IsVisible = !map2.IsVisible;
			};

			stack.Children.Add(map1);
			stack.Children.Add(map2);
			stack.Children.Add(btn);
			DisplayMaps();
			Content = stack;
		}
开发者ID:cosullivan,项目名称:Xamarin.Forms,代码行数:31,代码来源:Bugzilla38284.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# StackTracePolicy类代码示例发布时间:2022-05-24
下一篇:
C# StackFrame类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap