本文整理匯總了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;
}