當前位置: 首頁>>代碼示例>>C#>>正文


C# Forms.StackLayout類代碼示例

本文整理匯總了C#中Xamarin.Forms.StackLayout的典型用法代碼示例。如果您正苦於以下問題:C# StackLayout類的具體用法?C# StackLayout怎麽用?C# StackLayout使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StackLayout類屬於Xamarin.Forms命名空間,在下文中一共展示了StackLayout類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MenuCell

        public MenuCell()
        {
            image = new Image {
                HeightRequest = 20,
                WidthRequest = 20,
            };

            image.Opacity = 0.5;
               // image.SetBinding(Image.SourceProperty, ImageSrc);

            label = new Label
            {

                YAlign = TextAlignment.Center,
                TextColor = Color.Gray,
            };

            var layout = new StackLayout
            {
               // BackgroundColor = Color.FromHex("2C3E50"),
                BackgroundColor = Color.White,

                Padding = new Thickness(20, 0, 0, 0),
                Orientation = StackOrientation.Horizontal,
                Spacing = 20,
                //HorizontalOptions = LayoutOptions.StartAndExpand,
                Children = { image,label }
            };
            View = layout;
        }
開發者ID:segmond,項目名稱:CPXamarin,代碼行數:30,代碼來源:MenuCell.cs

示例2: GuidePageView

        public GuidePageView()
        {
            this.BackgroundColor = Color.Black;

            var layout = new StackLayout{ Padding = new Thickness (5, 10) };
            this.Title = "Help Page";
            layout.Children.Add (new Label {
                Text = "This will contain some helpful information.",
                FontSize = 30,
                TextColor = Color.White
            });

            var browser = new WebView ();
            var htmlSource = new HtmlWebViewSource ();
            htmlSource.Html = @"<iframe width=""300"" height=""200"" src=""https://www.youtube.com/embed/Y7bxlR-MxxM"" frameborder=""0"" allowfullscreen></iframe>";
            browser.Source = htmlSource;
            browser.HeightRequest = 215.0;
            browser.WidthRequest = 320.0;

            layout.Children.Add (browser);
            layout.Children.Add (
                new Button () {Text = "I'm ready to start",
                    Command = new Command (() => this.Navigation.PushAsync (new MainListViews ()))
                });
            this.Content = layout;
        }
開發者ID:adrianbrink,項目名稱:be-my-guide,代碼行數:26,代碼來源:GuidePageView.cs

示例3: OnAppearing

        protected override void OnAppearing()
        {
            base.OnAppearing ();

            var goXamlButton = new Button { Text = " Go With Xaml " , TextColor= Color.Black, BackgroundColor= Color.Gray};
            goXamlButton.Clicked += (sender, e) => {
                Navigation.PushAsync (new MenuPage());
            };

            var goCodeButton = new Button { Text = " Go With Code Only " , TextColor= Color.Black, BackgroundColor= Color.Gray };
            goCodeButton.Clicked += (sender, e) => {
                Navigation.PushAsync (new TodoListPage());
            };
            // The root page of your application
            Content = new StackLayout {
                VerticalOptions = LayoutOptions.Center,
                Children = {
                    new Label {
                        XAlign = TextAlignment.Center,
                        Text = "Welcome " + ((UserProfile)BindingContext).Name
                    },
                    goCodeButton,
                    goXamlButton
                }
            };
        }
開發者ID:dhinesh886,項目名稱:XamarinPOCRepo,代碼行數:26,代碼來源:WelcomePage.xaml.cs

示例4: MenuPage

		public MenuPage ()
		{
			Title = "LoginPattern";
			Icon = "slideout.png";

			var section = new TableSection () {
				new TextCell {Text = "Sessions"},
				new TextCell {Text = "Speakers"},
				new TextCell {Text = "Favorites"},
				new TextCell {Text = "Room Plan"},
				new TextCell {Text = "Map"},
			};

			var root = new TableRoot () {section} ;

			tableView = new TableView ()
			{ 
				Root = root,
				Intent = TableIntent.Menu,
			};

			var logoutButton = new Button { Text = "Logout" };
			logoutButton.Clicked += (sender, e) => {
				App.Current.Logout();
			};

			Content = new StackLayout {
				BackgroundColor = Color.Gray,
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = {
					tableView, 
					logoutButton
				}
			};
		}
開發者ID:ZaK14120,項目名稱:xamarin-forms-samples,代碼行數:35,代碼來源:MenuPage.cs

示例5: ListItemTemplate

		public ListItemTemplate ()
		{
			var photo = new Image { HeightRequest = 44, WidthRequest = 44 };
			photo.SetBinding (Image.SourceProperty, "Photo");

			var nameLabel = new Label { 
				VerticalTextAlignment = TextAlignment.Center,
				FontAttributes = FontAttributes.None,
				FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)),
			};

			nameLabel.SetBinding (Label.TextProperty, "Name");

			var titleLabel = new Label { 
				VerticalTextAlignment = TextAlignment.Center,
				FontAttributes = FontAttributes.None,
				FontSize = Device.GetNamedSize (NamedSize.Micro, typeof(Label)),
			};

			titleLabel.SetBinding (Label.TextProperty, "Title");

			var information = new StackLayout {
				Padding = new Thickness (5, 0, 0, 0),
				VerticalOptions = LayoutOptions.StartAndExpand,
				Orientation = StackOrientation.Vertical,
				Children = { nameLabel, titleLabel }
			};

			View = new StackLayout {
				Orientation = StackOrientation.Horizontal,
				Children = { photo, information }
			};
		}
開發者ID:RickySan65,項目名稱:xamarin-forms-samples,代碼行數:33,代碼來源:TableItems.cs

示例6: Login

        public Login()
        {
            Entry usuario = new Entry { Placeholder = "Usuario" };
            Entry clave = new Entry { Placeholder = "Clave", IsPassword = true };

            Button boton = new Button {
                Text = "Login",
                TextColor = Color.White,
                BackgroundColor = Color.FromHex ("77D065")
            };

            boton.Clicked += (sender, e) => {

            };

            //Stacklayout permite apilar los controles verticalmente
            StackLayout stackLayout = new StackLayout
            {
                Spacing = 20,
                Padding = 50,
                VerticalOptions = LayoutOptions.Center,
                Children =
                {
                    usuario,
                    clave,
                    boton
                }
            };

            //Como esta clase hereda de ContentPage, podemos usar estas propiedades directamente
            this.Content = stackLayout;
            this.Padding = new Thickness (5, Device.OnPlatform (20, 5, 5), 5, 5);
        }
開發者ID:narno67,項目名稱:Xamarin,代碼行數:33,代碼來源:Login.cs

示例7: CreateControls

		void CreateControls()
		{
			_picker = new DatePicker { Format = "D" };

			_manExpense = new Entry { Placeholder = "Exemple : 0,00", Keyboard = Keyboard.Numeric };
			_manExpense.TextChanged += numberEntry_TextChanged;
			_womanExpense = new Entry { Placeholder = "Exemple : 0,00", Keyboard = Keyboard.Numeric };
			_womanExpense.TextChanged += numberEntry_TextChanged;
			_details = new Editor { BackgroundColor = AppColors.Gray.MultiplyAlpha(0.15d), HeightRequest = 150 };

			Content = new StackLayout
				{ 
					Padding = new Thickness(20),
					Spacing = 10,
					Children =
						{
							new Label { Text = "Date" },
							_picker,
							new Label { Text = "Man expense" },
							_manExpense,
							new Label { Text = "Woman expense" },
							_womanExpense,
							new Label { Text = "Informations" },
							_details
						}
					};
		}
開發者ID:Benesss,項目名稱:ExpenseForms,代碼行數:27,代碼來源:AddPage.cs

示例8: CreateMiddleLayout

		static StackLayout CreateMiddleLayout()
		{

			//			var preBlank = new Label {
			//				Text = "",
			//				FontSize = 11
			//			};
			var preAbv = new Label {
				Text = "Abv",
				FontSize = 11,
				FontAttributes = FontAttributes.Bold
			};

			var preIbu = new Label {
				Text = "Ibu",
				FontSize = 11,
				FontAttributes = FontAttributes.Bold
			};


			var ctrlayout = new StackLayout()
			{
				//HorizontalOptions = LayoutOptions.Start,
				VerticalOptions = LayoutOptions.Center,
				Orientation = StackOrientation.Vertical,
				Children = {preIbu, preAbv }
			};

			return ctrlayout;
		}
開發者ID:fabianwilliams,項目名稱:JailBreakMobilePublic,代碼行數:30,代碼來源:ListOfBeerCell2.cs

示例9: MenuPage

		public MenuPage ()
		{
			Icon = "settings.png";
			Title = "Gráficos"; // The Title property must be set.
			BackgroundColor = Color.FromHex ("333333");

			Menu = new MenuListView ();

			var menuLabel = new ContentView {
				Padding = new Thickness (10, 36, 0, 5),
				Content = new Label {
					TextColor = Color.FromHex ("AAAAAA"),
					Text = "Gráficos", 
				}
			};

			var layout = new StackLayout { 
				Spacing = 0, 
				VerticalOptions = LayoutOptions.FillAndExpand
			};
			layout.Children.Add (menuLabel);
			layout.Children.Add (Menu);

			Content = layout;
		}
開發者ID:raynerhmc,項目名稱:XamarinFormsPesquera,代碼行數:25,代碼來源:MenuPage.cs

示例10: Setting

        public Setting()
        {
            var stack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Spacing = 10
            };

            var stack2 = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Spacing = 10,
                Padding = 10
            };

            var about = new Label
            {
                Font = Font.SystemFontOfSize(NamedSize.Medium),
                Text = "Setting",
                LineBreakMode = LineBreakMode.WordWrap
            };

            stack2.Children.Add(about);
            stack.Children.Add(new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand, Content = stack2 });
            Content = stack;

        }
開發者ID:XnainA,項目名稱:InsideInning,代碼行數:28,代碼來源:Setting.cs

示例11: BookChapterLabel

        public BookChapterLabel()
        {
            this.Orientation = StackOrientation.Horizontal;
            this.HorizontalOptions = LayoutOptions.FillAndExpand;
            this.VerticalOptions = LayoutOptions.StartAndExpand;

            // Book & chapter layout
            StackLayout bookChapter = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Spacing = 0,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            this.chapterLabel = new ChapterLabel();
            bookChapter.Children.Add(chapterLabel);

            this.bookLabel = new BookLabel();
            bookChapter.Children.Add(this.bookLabel);

            // Main layout
            this.settingsLabel = new SettingsLabel();
            this.Children.Add(this.settingsLabel);

            this.Children.Add(bookChapter);

            this.verseLabel = new VerseLabel();
            this.Children.Add(this.verseLabel);
        }
開發者ID:copticgem,項目名稱:inter,代碼行數:29,代碼來源:BookChapterLabel.cs

示例12: CreateNewCountLayout

        public StackLayout CreateNewCountLayout()
        {
            var lblCount = new Label()
            {
                HorizontalOptions = LayoutOptions.Start,
                FontSize = 24,
            };
            lblCount.SetBinding(Label.TextProperty, new Binding("Count" , stringFormat: "#{0}"));

            var lblPrice = new Label()
            {
                HorizontalOptions = LayoutOptions.End,
                FontSize = 24,
            };
            lblPrice.SetBinding(Label.TextProperty, new Binding("Price", stringFormat: "\t\t\t{0:C2}"));

            var countLayout = new StackLayout()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Orientation = StackOrientation.Horizontal,
                Children = { lblCount, lblPrice }
            };

            return countLayout;
        }
開發者ID:RoyStobbelaar,項目名稱:LubeckBeerCounter,代碼行數:25,代碼來源:LubeckBeerCard.cs

示例13: RssFeedView2

        public RssFeedView2()
        {
            this.viewModel = new RssFeedViewModel();
            this.BindingContext = viewModel;
            this.Title = "Rss Feed";

            var refresh = new ToolbarItem(){ Command = viewModel.ReloadCommand, Name = "Reload", Priority = 0 };
            ToolbarItems.Add(refresh);

            var stack = new StackLayout(){ Orientation = StackOrientation.Vertical };
            var activity = new ActivityIndicator(){ Color = Color.Blue, IsEnabled = true };
            activity.SetBinding(ActivityIndicator.IsVisibleProperty, "ShowActivityIndicator");
            activity.SetBinding(ActivityIndicator.IsRunningProperty, "ShowActivityIndicator");

            stack.Children.Add(activity);

            var listview = new ListView();
            listview.ItemsSource = viewModel.Records;
            var cell = new DataTemplate(typeof(ImageCell));
            cell.SetBinding(ImageCell.TextProperty, "Title");
            cell.SetBinding(ImageCell.ImageSourceProperty, "Image");
            listview.ItemTemplate = cell;
            listview.ItemSelected += async (sender, e) => {
                await Navigation.PushAsync(new RssWebView((RssRecordViewModel)e.SelectedItem));
                listview.SelectedItem = null;
            };

            stack.Children.Add(listview);

            Content = stack;
        }
開發者ID:jeffbmiller,項目名稱:RSSFeeds,代碼行數:31,代碼來源:RssFeedView2.cs

示例14: RequiredFieldTriggerPage

		public RequiredFieldTriggerPage ()
		{
			var l = new Label {
				Text = "Entry requires length>0 before button is enabled",
			};
			l.FontSize = Device.GetNamedSize (NamedSize.Small, l); 

			var e = new Entry { Placeholder = "enter name" };

			var b = new Button { Text = "Save",

				HorizontalOptions = LayoutOptions.Center
			};
			b.FontSize = Device.GetNamedSize (NamedSize.Large ,b);

			var dt = new DataTrigger (typeof(Button));
			dt.Binding = new Binding ("Text.Length", BindingMode.Default, source: e);
			dt.Value = 0;
			dt.Setters.Add (new Setter { Property = Button.IsEnabledProperty, Value = false });
			b.Triggers.Add (dt);

			Content = new StackLayout { 
				Padding = new Thickness(0,20,0,0),
				Children = {
					l,
					e,
					b
				}
			};
		}
開發者ID:ChandrakanthBCK,項目名稱:xamarin-forms-samples,代碼行數:30,代碼來源:RequiredFieldTriggerPage.cs

示例15: TodoItemCell

		public TodoItemCell ()
		{
			StyleId = "Cell";

			var label = new Label {
				StyleId = "CellLabel",
				YAlign = TextAlignment.Center,
				HorizontalOptions = LayoutOptions.StartAndExpand
			};
			label.SetBinding (Label.TextProperty, "Name");

			var tick = new Image {
				StyleId = "CellTick",
				Source = FileImageSource.FromFile ("check"),
				HorizontalOptions = LayoutOptions.End
			};
			tick.SetBinding (Image.IsVisibleProperty, "Done");

			var layout = new StackLayout {
				Padding = new Thickness(20, 0, 20, 0),
				Orientation = StackOrientation.Horizontal,
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Children = {label, tick}
			};
			View = layout;
		}
開發者ID:crcossey,項目名稱:xamarin-forms-samples,代碼行數:26,代碼來源:TodoItemCell.cs


注:本文中的Xamarin.Forms.StackLayout類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。