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

C# Forms.Label类代码示例

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

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



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


示例16: CustomCell

            public CustomCell()
            {
                //instantiate each of our views
                var image = new Image();
                StackLayout cellWrapper = new StackLayout();
                StackLayout horizontalLayout = new StackLayout();
                Label left = new Label();
                Label right = new Label();

                //set bindings
                left.SetBinding(Label.TextProperty, "name");
                right.SetBinding(Label.TextProperty, "description");
                image.SetBinding(Image.SourceProperty, "profileIcon");

                //Set properties for desired design
                cellWrapper.BackgroundColor = Color.FromHex("#eee");
                horizontalLayout.Orientation = StackOrientation.Horizontal;
                right.HorizontalOptions = LayoutOptions.EndAndExpand;
                left.TextColor = Color.FromHex("#f35e20");
                right.TextColor = Color.FromHex("503026");

                //add views to the view hierarchy
                horizontalLayout.Children.Add(image);
                horizontalLayout.Children.Add(left);
                horizontalLayout.Children.Add(right);
                cellWrapper.Children.Add(horizontalLayout);
                View = cellWrapper;
            }
开发者ID:sabeersulaiman,项目名称:OAuthTwoDemo.XForms,代码行数:28,代码来源:ProfilePage.cs


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


示例18: MenuListTemplate

        public MenuListTemplate()
        {
            List<MenuItem> data = new MenuListData();
            this.ItemsSource = data;
            this.VerticalOptions = LayoutOptions.FillAndExpand;
            this.BackgroundColor = Theme.NavBackgroundColor;
            this.SeparatorColor = Color.Black;
            this.Margin = new Thickness(5);

            var menuDataTemplate = new DataTemplate(() =>
            {
                var pageImage = new Image
                {
                    VerticalOptions = LayoutOptions.Center,
                    HeightRequest = 30,
                    Margin = new Thickness(0, 0, 10, 0)
                };
                var pageLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    TextColor = Theme.TextColor,
                    FontSize = 20,
                };

                pageImage.SetBinding(Image.SourceProperty, "IconSource");
                pageLabel.SetBinding(Label.TextProperty, "Name");

                var layout = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    VerticalOptions = LayoutOptions.Center,
                    Children =
                    {
                        pageImage,
                        pageLabel
                    }
                };

                var menuFrame = new Frame
                {
                    OutlineColor = Theme.NavBackgroundColor,
                    BackgroundColor = Theme.NavBackgroundColor,
                    VerticalOptions = LayoutOptions.Center,
                    Padding = new Thickness(10),
                    Content = layout
                };

                return new ViewCell { View = menuFrame };
            });



            var cell = new DataTemplate(typeof(ViewCell));
            cell.SetBinding(TextCell.TextProperty, "Name");
            cell.SetValue(TextCell.TextColorProperty, Color.FromHex("2f4f4f"));


            this.ItemTemplate = menuDataTemplate;
            this.SelectedItem = data[0];
        }
开发者ID:threezool,项目名称:LaunchPal,代码行数:60,代码来源:MenuListTemplate.cs


示例19: SwitchCellDemoPage

        public SwitchCellDemoPage()
        {
            Label header = new Label
            {
                Text = "SwitchCell",
                Font = Font.SystemFontOfSize(50, FontAttributes.Bold),
                HorizontalOptions = LayoutOptions.Center
            };

            TableView tableView = new TableView
            {
                Intent = TableIntent.Form,
                Root = new TableRoot
                {
                    new TableSection
                    {
                        new SwitchCell
                        {
                            Text = "SwitchCell:"
                        }
                    }
                }
            };

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


示例20: Foo

        private void Foo()
        {

            Page p = new Page
            {
                //BackgroundColor = "white",
            };

            var l = new Label
            {
                Font = Font.SystemFontOfSize(NamedSize.Micro),
            };

            var e = new Entry()
            {

                Keyboard = Keyboard.Numeric,
                VerticalOptions = LayoutOptions.FillAndExpand,
            };


            var c = new ContentView()
            {
                Padding = new Thickness(5),
            };

            var sl = new StackLayout
            {
                Padding = new Thickness(5),
            };
        }
开发者ID:adbk,项目名称:spikes,代码行数:31,代码来源:Spike.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Forms.Page类代码示例发布时间:2022-05-26
下一篇:
C# Forms.Grid类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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