本文整理汇总了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;
}