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


C# ContentPage.SetBinding方法代码示例

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


在下文中一共展示了ContentPage.SetBinding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TabbedPageDemoPageCS

		public TabbedPageDemoPageCS ()
		{
			var booleanConverter = new NonNullToBooleanConverter ();

			ItemTemplate = new DataTemplate (() => {
				var nameLabel = new Label {
					FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
					FontAttributes = FontAttributes.Bold,
					HorizontalOptions = LayoutOptions.Center
				};
				nameLabel.SetBinding (Label.TextProperty, "Name");

				var image = new Image { WidthRequest = 200, HeightRequest = 200 };
				image.SetBinding (Image.SourceProperty, "PhotoUrl");

				var familyLabel = new Label {
					FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)),
					FontAttributes = FontAttributes.Bold
				};
				familyLabel.SetBinding (Label.TextProperty, "Family");

				var subFamilyLabel = new Label {
					FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)),
					FontAttributes = FontAttributes.Bold
				};
				subFamilyLabel.SetBinding (Label.TextProperty, "Subfamily");

				var tribeLabel = new Label {
					FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)),
					FontAttributes = FontAttributes.Bold
				};
				tribeLabel.SetBinding (Label.TextProperty, "Tribe");

				var genusLabel = new Label {
					FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)),
					FontAttributes = FontAttributes.Bold
				};
				genusLabel.SetBinding (Label.TextProperty, "Genus");

				var subFamilyStackLayout = new StackLayout {
					Orientation = StackOrientation.Horizontal,
					Children = {
						new Label { Text = "Subfamily:", HorizontalOptions = LayoutOptions.FillAndExpand }, 
						subFamilyLabel
					}
				};				
				subFamilyStackLayout.SetBinding (VisualElement.IsVisibleProperty, new Binding ("Subfamily", BindingMode.Default, booleanConverter));

				var tribeStackLayout = new StackLayout { 
					Orientation = StackOrientation.Horizontal,
					Children = {
						new Label { Text = "Tribe:", HorizontalOptions = LayoutOptions.FillAndExpand },
						tribeLabel
					}	
				};
				tribeStackLayout.SetBinding (VisualElement.IsVisibleProperty, new Binding ("Tribe", BindingMode.Default, booleanConverter));

				var contentPage = new ContentPage {
					Icon = "monkeyicon.png",
					Content = new StackLayout {
						Padding = new Thickness (5, 25),
						Children = {
							nameLabel,
							image,
							new StackLayout {
								Padding = new Thickness (50, 10),
								Children = {
									new StackLayout { 
										Orientation = StackOrientation.Horizontal,
										Children = {
											new Label { Text = "Family:", HorizontalOptions = LayoutOptions.FillAndExpand },
											familyLabel
										}
									},
									subFamilyStackLayout,
									tribeStackLayout,
									new StackLayout {
										Orientation = StackOrientation.Horizontal,
										Children = {
											new Label { Text = "Genus:", HorizontalOptions = LayoutOptions.FillAndExpand },
											genusLabel
										}
									} 
								}
							} 

						}
					}
				};
				contentPage.SetBinding (TitleProperty, "Name");

				return contentPage;
			});

			ItemsSource = MonkeyDataModel.All;
		}
开发者ID:B3ND3R,项目名称:recipes,代码行数:96,代码来源:TabbedPageDemoPageCS.cs


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