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


C# Forms.Label类代码示例

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


Label类属于Xamarin.Forms命名空间,在下文中一共展示了Label类的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: NetworkStatusPage

        public NetworkStatusPage()
        {
            var networkLabel = new Label {
                Text = "Network Status",
                YAlign = TextAlignment.Center
            };
            var networkBox = new BoxView {
                Color = Color.White,
                HeightRequest = 25,
                WidthRequest = 25
            };

            var networkStack = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                Padding = 15,
                Spacing = 25,
                Children = { networkLabel, networkBox }
            };

            var button = new Button {
                Text = "Update Status",
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            button.Clicked += (sender, e) => {
                var service = DependencyService.Get<INetworkService>();
                var isConnected = service.IsConnected();

                networkBox.Color = isConnected ? Color.Green : Color.Red;
            };

            Content = new StackLayout {
                Children = { networkStack, button }
            };
        }
开发者ID:ardiprakasa,项目名称:create-cross-platform-mobile-apps-with-xamarinforms,代码行数:35,代码来源:NetworkStatusPage.cs

示例3: 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

示例4: InitializeComponent

 private void InitializeComponent()
 {
     this.LoadFromXaml(typeof(MatrixControlPrototype));
     cnvTitle = this.FindByName<ContentView>("cnvTitle");
     lblTitle = this.FindByName<Label>("lblTitle");
     rootCanvas = this.FindByName<AbsoluteLayout>("rootCanvas");
 }
开发者ID:LordOfSmiles,项目名称:MatrixBuilderTest,代码行数:7,代码来源:MatrixBuilderTest.Controls.Prototypes.MatrixControlPrototype.xaml.g.cs

示例5: CreateMiddleRightLayout

		static StackLayout CreateMiddleRightLayout()
		{
			var ibuLabel = new Label
			{
				HorizontalOptions= LayoutOptions.StartAndExpand,
				FontSize = 11
			};
			ibuLabel.SetBinding(Label.TextProperty, "Ibu");

			var abvLabel = new Label
			{
				HorizontalOptions= LayoutOptions.StartAndExpand,
				FontSize = 11
			};
			abvLabel.SetBinding(Label.TextProperty, "Abv");

			var ctrrghtlayout = new StackLayout ()
			{
				VerticalOptions = LayoutOptions.Center,
				Orientation = StackOrientation.Vertical,
				Children = {ibuLabel, abvLabel }
			};

			return ctrrghtlayout;
		}
开发者ID:fabianwilliams,项目名称:JailBreakMobilePublic,代码行数:25,代码来源:ListOfBeerCell2.cs

示例6: WebViewDemoPage

        public WebViewDemoPage()
        {
            Label header = new Label
            {
                Text = "WebView",
				FontSize = 50,
				FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            WebView webView = new WebView
            {
                Source = new UrlWebViewSource
                {
                    Url = "https://blog.xamarin.com/",
                },
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    webView
                }
            };
        }
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:29,代码来源:WebViewDemoPage.cs

示例7: ListOfBeerCell2

		public ListOfBeerCell2 ()
		{
			var preBlank = new Label {
				Text = "",
				FontSize = 11
			};

			var image = new Image
			{
				Aspect = Aspect.AspectFill,
				//WidthRequest = 150,

				HorizontalOptions = LayoutOptions.Start,
				VerticalOptions = LayoutOptions.Center
			};
			image.SetBinding(Image.SourceProperty, new Binding("ProName"));

			var rslayout = CreateRightSideLayout ();

			var ctrlayout = CreateMiddleLayout ();

			var ctrrghtlayout = CreateMiddleRightLayout ();

			var leftImageLayout = new StackLayout()
			{
				Spacing = 2,
				Padding = new Thickness (5, 5, 0, 5),
				VerticalOptions = LayoutOptions.Center,
				Orientation = StackOrientation.Horizontal,
				Children = {image, ctrlayout, ctrrghtlayout, rslayout}
			};
			View = leftImageLayout;
		}
开发者ID:fabianwilliams,项目名称:JailBreakMobilePublic,代码行数:33,代码来源:ListOfBeerCell2.cs

示例8: Pagina1

        public Pagina1()
        {
            Label texto = new Label {
                Text = "Página 1",
                TextColor = Color.Blue
            };

            Button boton = new Button
            {
                Text = "Click para navegar a la página DOS"
            };

            boton.Clicked += (sender, e) => {
                this.Navigation.PushAsync(new Pagina2());
            };

            //Stacklayout permite apilar los controles verticalmente
            StackLayout stackLayout = new StackLayout
            {
                Children =
                {
                    texto,
                    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:dtorress,项目名称:XamActivities,代码行数:30,代码来源:Pagina1.cs

示例9: MyMasterDetail

        public MyMasterDetail()
        {
            Label header = new Label
            {
                Text = "MasterDetailPage",
                FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                HorizontalOptions = LayoutOptions.Center
            };
            string[] myList = new string[10];
            myList[0] = "Content Demo";
            //myList [1] = "Tabbed Demo";
            //myList[2] = "Carousel Demo";
            ListView listView = new ListView
            {
                ItemsSource = myList
            };
            this.Master = new ContentPage
            {
                Title = header.Text,
                Content = new StackLayout
                {
                    Children =
                    {
                        header,
                        listView

                    }
                    }
            };
            this.Detail = new NavigationPage(new HomePage());
        }
开发者ID:CTS458641,项目名称:cts458701,代码行数:31,代码来源:MyMasterDetail.cs

示例10: XFormsPortableRunner

 public XFormsPortableRunner(Label mainLabel, Label testsLabel, Action<Action> uiRunner)
     : base()
 {
     _mainLabel = mainLabel;
     _testsLabel = testsLabel;
     _uiRunner = uiRunner;
 }
开发者ID:lawandeneel,项目名称:Fashion,代码行数:7,代码来源:XFormsPortableRunner.cs

示例11: DatePickerDemoPage

        public DatePickerDemoPage()
        {
            Label header = new Label
            {
                Text = "DatePicker",
                Font = Font.BoldSystemFontOfSize(50),
                HorizontalOptions = LayoutOptions.Center
            };

            DatePicker datePicker = new DatePicker
            {
                Format = "D",
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            // Accomodate iPhone status bar.
            this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    datePicker
                }
            };
        }
开发者ID:Biotelligent,项目名称:xamarin-forms-samples,代码行数:28,代码来源:DatePickerDemoPage.cs

示例12: SessionCell

		public SessionCell ()
		{
			title = new Label {
				YAlign = TextAlignment.Center
			};
			title.SetBinding (Label.TextProperty, "Title");

			label = new Label {
				YAlign = TextAlignment.Center,
				Font = Font.SystemFontOfSize(10)
			};
			label.SetBinding (Label.TextProperty, "LocationDisplay");

			var fav = new Image {
				Source = FileImageSource.FromFile ("favorite.png"),
			};
			//TODO: implement favorites
			//fav.SetBinding (Image.IsVisibleProperty, "IsFavorite");

			var text = new StackLayout {
				Orientation = StackOrientation.Vertical,
				Padding = new Thickness(0, 0, 0, 0),
				HorizontalOptions = LayoutOptions.StartAndExpand,
				Children = {title, label}
			};

			layout = new StackLayout {
				Padding = new Thickness(20, 0, 0, 0),
				Orientation = StackOrientation.Horizontal,
				HorizontalOptions = LayoutOptions.StartAndExpand,
				Children = {text, fav}
			};
			View = layout;
		}
开发者ID:Randy3W,项目名称:xamarin-forms-samples,代码行数:34,代码来源:SessionCell.cs

示例13: CreateCellView

        private Xamarin.Forms.View CreateCellView(string content, int colIndex, int rowIndex)
        {
            // Create the container view
            var container = new StackLayout()
            {
                BackgroundColor = rowIndex == 0 ? Color.Black : Color.White,
                Padding = new Thickness(10)
            };

            // Create the label
            var label = new Label()
            {
                Text = rowIndex == 0 ? content : content.Replace(",", "\r\n"),
                BackgroundColor = rowIndex == 0 ? Color.Black : Color.White,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalTextAlignment = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Start,
                TextColor = rowIndex == 0 ? Color.White : Color.Black,
                FontSize = 12,
                LineBreakMode = LineBreakMode.WordWrap
            };

            if (rowIndex == 0)
            {
                label.FontAttributes = FontAttributes.Bold;
            }

            label.SetBinding(Label.FontFamilyProperty, new Binding(path: "FontFamily", source: this));

            container.Children.Add(label);

            // Return...
            return container;
        }
开发者ID:Manne990,项目名称:XamTest,代码行数:35,代码来源:TableView.cs

示例14: GamePage

        public GamePage()
        {
            var message = new Label {
                Text = "Click the unicorn!"
            };

            UpdateTimeLabel ();

            var unicorn = new ImageCell {
                ImageSource = ImageSource.FromFile ("Unicorn.png"),
            };

            unicorn.Tapped += (sender, e) => {
                if(_playing){
                    _clickCount++;
                    message.Text = string.Format ("Clicked {0} times", _clickCount);
                }
            };

            Content = new StackLayout {
                VerticalOptions = LayoutOptions.Center,
                Children = {
                    new TableView {
                        Intent = TableIntent.Form,
                        RowHeight = 300,
                        Root = new TableRoot { new TableSection { unicorn } }
                    },
                    message,
                    _timeLabel
                }
            };

            Device.StartTimer (TimeSpan.FromSeconds (1), HandleSecondTick);
        }
开发者ID:AntonMaltsev,项目名称:UnicornStore,代码行数:34,代码来源:GamePage.cs

示例15: CreateNewInfoLayout

        public StackLayout CreateNewInfoLayout()
        {
            //BeerName
            var beerName = new Label()
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                FontSize = 12,
            };
            beerName.SetBinding(Label.TextProperty, new Binding("beerName",stringFormat: "{0}"));

            //BeerPrice
            var beerPrice = new Label()
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                FontSize = 12,
            };
            beerPrice.SetBinding(Label.TextProperty, new Binding("cost", stringFormat: "price: {0}"));

            //Layout
            var infoLayout = new StackLayout()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Orientation = StackOrientation.Horizontal,
                Children = { beerName,  beerPrice }
            };

            return infoLayout;
        }
开发者ID:RoyStobbelaar,项目名称:LubeckBeerCounter,代码行数:28,代码来源:LubeckBeerCard.cs


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