當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。