本文整理汇总了C#中Xamarin.Forms.StackLayout.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# StackLayout.SetBinding方法的具体用法?C# StackLayout.SetBinding怎么用?C# StackLayout.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xamarin.Forms.StackLayout
的用法示例。
在下文中一共展示了StackLayout.SetBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: sideCustomViewCell
public sideCustomViewCell()
{
StackLayout s = new StackLayout {
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
Orientation = StackOrientation.Horizontal,
Padding = 10,
Spacing = 10
};
s.SetBinding (StackLayout.BackgroundColorProperty, "Background");
Label l = new Label {
FontSize = 17,
FontAttributes = FontAttributes.Bold,
XAlign = TextAlignment.Center,
YAlign = TextAlignment.Center
};
l.SetBinding (Label.TextProperty, "Title");
l.SetBinding (Label.TextColorProperty, "TextColour");
Image i = new Image {
};
i.SetBinding (Image.SourceProperty, "IconSource");
s.Children.Add (i);
s.Children.Add (l);
this.View = s;
}
示例2: MenuImageCell
public MenuImageCell()
: base()
{
Label Text = new Label {
TextColor = Color.FromHex ("DCDCDC"),
XAlign = TextAlignment.Start,
YAlign = TextAlignment.Center
};
Text.SetBinding (Label.TextProperty, "Title");
Label pad = new Label {
Text = " "
};
Image image = new Image {
// Backup: Default icon to set
//Source = "info.png",
HeightRequest = 30,
};
image.SetBinding (Image.SourceProperty, "Icon");
var layout = new StackLayout {
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.Center,
Children = { pad, image, pad, Text }
};
layout.SetBinding (Layout.BackgroundColorProperty, new Binding ("BackgroundColor"));
if (Device.OS == TargetPlatform.WinPhone)
layout.HeightRequest = 50;
View = layout;
}
示例3: OpcionesCell
public OpcionesCell()
{
var image = new Image
{
HorizontalOptions = LayoutOptions.Start,
};
image.SetBinding(Image.SourceProperty, new Binding("Imagen"));
image.SetBinding(Image.BackgroundColorProperty, new Binding("ColorFondo", BindingMode.OneWay, new ColorConverter()));
image.WidthRequest = image.HeightRequest = 24;
var nameLabel = new Label
{
HorizontalOptions = LayoutOptions.FillAndExpand,
TextColor = Color.Black,
BackgroundColor = Color.Gray
};
nameLabel.SetBinding(Label.TextProperty, "Nombre");
nameLabel.SetBinding(Label.BackgroundColorProperty, new Binding("ColorFondo", BindingMode.OneWay, new ColorConverter()));
var viewLayout = new StackLayout()
{
Orientation = StackOrientation.Horizontal,
VerticalOptions = LayoutOptions.CenterAndExpand,
Children = { image, nameLabel}
};
viewLayout.SetBinding(StackLayout.BackgroundColorProperty, new Binding("ColorFondo", BindingMode.OneWay, new ColorConverter()));
View = viewLayout;
}
示例4: JobHeaderView
public JobHeaderView()
{
var number = new Label();
number.TextColor = Color.White;
number.WidthRequest = 30;
number.Font = AppStyle.DefaultFont.WithSize(NamedSize.Large).WithAttributes(FontAttributes.Bold);
number.SetBinding<Job>(Label.TextProperty, job => job.JobNumber);
var eta = new Label();
eta.VerticalOptions = LayoutOptions.FillAndExpand;
eta.HorizontalOptions = LayoutOptions.FillAndExpand;
eta.YAlign = TextAlignment.Center;
eta.TextColor = Color.White;
eta.Font = AppStyle.DefaultFont;
eta.SetBinding<Job>(Label.TextProperty, job => job.EtaTime);
var rootLayout = new StackLayout
{
Orientation = StackOrientation.Horizontal,
Padding = 5,
Children = { number, eta }
};
rootLayout.SetBinding<Job>(StackLayout.BackgroundColorProperty, job => job.Status, converter: new JobStatusToColorConverter());
this.Content = rootLayout;
}
示例5: JobHeaderView
public JobHeaderView()
{
var number = new Label();
number.TextColor = Color.White;
number.WidthRequest = 60;
number.FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label));
number.FontAttributes = FontAttributes.Bold;
number.SetBinding<Job>(Label.TextProperty, job => job.JobNumber);
var eta = new Label();
eta.VerticalOptions = LayoutOptions.FillAndExpand;
eta.HorizontalOptions = LayoutOptions.FillAndExpand;
eta.YAlign = TextAlignment.Center;
eta.TextColor = Color.White;
//eta.Font = AppStyle.DefaultFont;
eta.SetBinding<Job>(Label.TextProperty, job => job.StartTime);
var name = new Label();
name.VerticalOptions = LayoutOptions.FillAndExpand;
name.HorizontalOptions = LayoutOptions.FillAndExpand;
name.YAlign = TextAlignment.Center;
name.TextColor = Color.White;
//name.Font = AppStyle.DefaultFont;
name.SetBinding<Job>(Label.TextProperty, job => job.CustomerName);
var rootLayout = new StackLayout
{
Orientation = StackOrientation.Horizontal,
Padding = 5,
Children = { number, eta, name }
};
rootLayout.SetBinding<Job>(StackLayout.BackgroundColorProperty, job => job.Status, converter: new JobStatusToColorConverter());
this.Content = rootLayout;
}
示例6: MenuViewCell
public MenuViewCell()
{
var img = new Image
{
VerticalOptions = LayoutOptions.Start
};
img.SetBinding(Image.SourceProperty, "Icone");
var lblMenu = new Label
{
Style = Estilos._estiloFonteMenu
};
lblMenu.SetBinding(Label.TextProperty, "Titulo");
var mainLayout = new StackLayout
{
Orientation = StackOrientation.Horizontal,
VerticalOptions = LayoutOptions.FillAndExpand,
Children = { img, lblMenu },
Padding = 10
};
mainLayout.SetBinding(StackLayout.BackgroundColorProperty, "Color");
this.View = mainLayout;
}
示例7: ActiveChatsPage
public ActiveChatsPage(ViewModelBase viewModel)
: base(viewModel)
{
var listView = new BindableListView
{
ItemTemplate = new DataTemplate(() =>
{
var imageCell = new ImageCell();
imageCell.SetBinding(ImageCell.TextProperty, new Binding("Name"));
imageCell.SetBinding(ImageCell.DetailProperty, new Binding("DescriptionText"));
imageCell.SetBinding(ImageCell.ImageSourceProperty, new Binding("Image"));
imageCell.TextColor = Styling.CellTitleColor;
imageCell.DetailColor = Styling.CellDetailColor;
return imageCell;
}),
SeparatorVisibility = SeparatorVisibility.None
};
listView.SetBinding(ListView.ItemsSourceProperty, new Binding("ActiveChats"));
listView.SetBinding(BindableListView.ItemClickedCommandProperty, new Binding("SelectActiveChatCommand"));
listView.SetBinding(ListView.IsVisibleProperty, new Binding("HasConversations", BindingMode.OneWay));
var noItemsLabel = new Label {
Text = "Start a conversation or open a room!",
HorizontalOptions = LayoutOptions.Center,
FontSize = 16,
TextColor = Color.Gray
};
var noItemsLayout = new StackLayout
{
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Children =
{
new BoxView{HeightRequest = 20},
noItemsLabel
}
};
noItemsLayout.SetBinding(StackLayout.IsVisibleProperty, new Binding("HasConversations", BindingMode.OneWay, converter: new InverterConverter()));
var loadingIndicator = new ActivityIndicator ();
loadingIndicator.SetBinding(ActivityIndicator.IsRunningProperty, new Binding("IsBusy"));
loadingIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, new Binding("IsBusy"));
Content = new StackLayout
{
Children =
{
loadingIndicator,
listView,
noItemsLayout
}
};
}
示例8: CreateNoSessionStack
static StackLayout CreateNoSessionStack ()
{
var noSessionStack = new StackLayout
{
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.StartAndExpand,
VerticalOptions = LayoutOptions.EndAndExpand,
Spacing = 10
};
noSessionStack.SetBinding (Frame.IsVisibleProperty, "IsBooked", converter: new NegateValueConverter ());
noSessionStack.Children.Add (CreateAddIcon ());
noSessionStack.Children.Add (CreateNoSessionLabel ());
return noSessionStack;
}
示例9: MainPage
public MainPage ()
{
Title = "TripLog";
var itemTemplate = new DataTemplate (typeof(TextCell));
itemTemplate.SetBinding (TextCell.TextProperty, "Title");
itemTemplate.SetBinding (TextCell.DetailProperty, "Notes");
var entries = new ListView {
ItemTemplate = itemTemplate
};
entries.SetBinding (ListView.ItemsSourceProperty, "LogEntries");
entries.SetBinding (ListView.IsVisibleProperty, "IsBusy", converter: new ReverseBooleanConverter());
entries.ItemTapped += (sender, e) =>
{
var item = (TripLogEntry) e.Item;
vm.ViewCommand.Execute (item);
};
var newButton = new ToolbarItem { Text = "New" };
newButton.SetBinding (ToolbarItem.CommandProperty, "NewCommand");
ToolbarItems.Add (newButton);
var loading = new StackLayout {
Orientation = StackOrientation.Vertical,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
Children = {
new ActivityIndicator {
IsRunning = true
},
new Label {
Text = "Loading Entries..."
}
}
};
loading.SetBinding (StackLayout.IsVisibleProperty, "IsBusy");
var mainLayout = new Grid {
Children = {
entries,
loading
}
};
Content = mainLayout;
}
示例10: CreateRootStack
View CreateRootStack ()
{
var stack = new StackLayout {
Orientation = StackOrientation.Horizontal,
Padding = 12,
Children = {
new SessionItem (),
CreateSelectionIndicator ()
}
};
stack.SetBinding (StackLayout.BackgroundColorProperty, "Track",
converter: new TrackBackgroundColorConverter ());
return stack;
}
示例11: JobCell
public JobCell()
{
var jobHeader = new JobHeaderView();
var title = new Label();
//title.Font = AppStyle.DefaultFont;
title.SetBinding<Job>(Label.TextProperty, job => job.Title);
var customer = new Label();
//customer.Font = AppStyle.DefaultFont;
customer.SetBinding<Job>(Label.TextProperty, job => job.CustomerName);
var jobDetails = new StackLayout
{
Orientation = StackOrientation.Vertical,
Padding = 5,
Children =
{
new StackLayout
{
Orientation = StackOrientation.Horizontal,
Children = {
new Label { Text = "Customer:", FontAttributes = FontAttributes.Bold },
customer
}
},
new Label { Text = "Description:", FontAttributes = FontAttributes.Bold },
title
}
};
jobDetails.SetBinding<Job>(StackLayout.BackgroundColorProperty, job => job.Status, converter: new JobStatusToColorConverter(useLightTheme: true));
var rootLayout = new StackLayout()
{
Orientation = StackOrientation.Vertical,
Spacing = 0,
Children =
{
jobHeader,
jobDetails
}
};
this.Height = 130;
this.View = rootLayout;
}
示例12: CreateTopRow
static View CreateTopRow ()
{
var profile = new StackLayout {
Orientation = StackOrientation.Horizontal,
Spacing = 18,
HeightRequest = 50,
Padding = new Thickness (20, 40, 10, 10),
//BackgroundColor = Color.Green,
Children = {
CreateQRBox (),
CreateNameStack ()
}
};
profile.SetBinding(StackLayout.IsVisibleProperty, "HasProfile");
var profileTapGesture = new TapGestureRecognizer();
profileTapGesture.SetBinding (TapGestureRecognizer.CommandProperty, "AddContactCommand");
profile.GestureRecognizers.Add (profileTapGesture);
var noProfile = new StackLayout {
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.CenterAndExpand,
Spacing = 18,
HeightRequest = 50,
Padding = new Thickness (20, 40, 10, 10),
//BackgroundColor = Color.Red,
Children = {
CreateNoProfileView ()
}
};
noProfile.SetBinding(StackLayout.IsVisibleProperty, "HasProfile", converter: new NegateValueConverter());
var noProfileTapGesture = new TapGestureRecognizer();
noProfileTapGesture.SetBinding<MenuViewModel> (TapGestureRecognizer.CommandProperty, vm => vm.CreateProfileCommand);
noProfile.GestureRecognizers.Add (noProfileTapGesture);
var grid = new Grid {
Children = {
profile,
noProfile
}
};
return grid;
}
示例13: JobHeaderView
public JobHeaderView(double leftPadding, bool colorBackground = false)
{
var eta = new Label();
eta.VerticalOptions = LayoutOptions.FillAndExpand;
eta.HorizontalOptions = LayoutOptions.FillAndExpand;
eta.VerticalTextAlignment = TextAlignment.Start;
eta.SetBinding<Job>(Label.TextProperty, job => job.StartTime, stringFormat: "Start time: {0}");
var rootLayout = new StackLayout {
Orientation = StackOrientation.Horizontal,
Padding = new Thickness(leftPadding, 5, 0, 5),
Children = { eta }
};
if (colorBackground) {
eta.TextColor = Color.White;
rootLayout.SetBinding<Job>(StackLayout.BackgroundColorProperty, job => job.Status, converter: new JobStatusToColorConverter());
}
this.Content = rootLayout;
}
示例14: JobGroupingHeaderCell
public JobGroupingHeaderCell()
{
var title = new Label
{
Font = AppStyle.DefaultFont.WithSize(NamedSize.Medium).WithAttributes(FontAttributes.Bold),
TextColor = Color.White,
VerticalOptions = LayoutOptions.Center
};
title.SetBinding(Label.TextProperty, new Binding("Key", stringFormat: "Job Status: {0}"));
var layout = new StackLayout
{
Padding = 5,
Orientation = StackOrientation.Horizontal,
Children = { title }
};
layout.SetBinding(StackLayout.BackgroundColorProperty, "Key", converter: new JobStatusToColorConverter());
this.Height = 35;
this.View = layout;
}
示例15: MenuCell
public MenuCell()
{
//instantiate each of our views
StackLayout stckMenuWrapper = new StackLayout ();
StackLayout stckHorizontalMenuWrapper = new StackLayout ();
StackLayout stckVerticalWrapper = new StackLayout ();
Image imagem = new Image ();
BoxView separador = new BoxView ();
Label title = new Label ();
Label descrption = new Label ();
//set bindings
imagem.SetBinding (Image.SourceProperty, "Image");
title.SetBinding (Label.TextProperty, "DisplayName");
descrption.SetBinding (Label.TextProperty, "Description");
stckHorizontalMenuWrapper.SetBinding (StackLayout.BackgroundColorProperty, "BackgroundColor");
//set properties
stckMenuWrapper.Orientation = StackOrientation.Vertical;
stckHorizontalMenuWrapper.Orientation = StackOrientation.Horizontal;
stckVerticalWrapper.Orientation = StackOrientation.Vertical;
stckHorizontalMenuWrapper.Padding = new Thickness (10);
separador.BackgroundColor = Color.Transparent;
separador.IsEnabled = false;
title.TextColor = Color.White;
descrption.TextColor = Color.White;
title.FontSize = 21;
descrption.FontSize = 12;
//add views to the view hierarchy
stckVerticalWrapper.Children.Add(title);
stckVerticalWrapper.Children.Add(descrption);
stckHorizontalMenuWrapper.Children.Add(imagem);
stckHorizontalMenuWrapper.Children.Add(stckVerticalWrapper);
stckMenuWrapper.Children.Add (stckHorizontalMenuWrapper);
stckMenuWrapper.Children.Add (separador);
View = stckMenuWrapper;
}