本文整理汇总了C#中Xamarin.Forms.StackLayout类的典型用法代码示例。如果您正苦于以下问题:C# StackLayout类的具体用法?C# StackLayout怎么用?C# StackLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StackLayout类属于Xamarin.Forms命名空间,在下文中一共展示了StackLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: GuidePageView
public GuidePageView()
{
this.BackgroundColor = Color.Black;
var layout = new StackLayout{ Padding = new Thickness (5, 10) };
this.Title = "Help Page";
layout.Children.Add (new Label {
Text = "This will contain some helpful information.",
FontSize = 30,
TextColor = Color.White
});
var browser = new WebView ();
var htmlSource = new HtmlWebViewSource ();
htmlSource.Html = @"<iframe width=""300"" height=""200"" src=""https://www.youtube.com/embed/Y7bxlR-MxxM"" frameborder=""0"" allowfullscreen></iframe>";
browser.Source = htmlSource;
browser.HeightRequest = 215.0;
browser.WidthRequest = 320.0;
layout.Children.Add (browser);
layout.Children.Add (
new Button () {Text = "I'm ready to start",
Command = new Command (() => this.Navigation.PushAsync (new MainListViews ()))
});
this.Content = layout;
}
示例3: OnAppearing
protected override void OnAppearing()
{
base.OnAppearing ();
var goXamlButton = new Button { Text = " Go With Xaml " , TextColor= Color.Black, BackgroundColor= Color.Gray};
goXamlButton.Clicked += (sender, e) => {
Navigation.PushAsync (new MenuPage());
};
var goCodeButton = new Button { Text = " Go With Code Only " , TextColor= Color.Black, BackgroundColor= Color.Gray };
goCodeButton.Clicked += (sender, e) => {
Navigation.PushAsync (new TodoListPage());
};
// The root page of your application
Content = new StackLayout {
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "Welcome " + ((UserProfile)BindingContext).Name
},
goCodeButton,
goXamlButton
}
};
}
示例4: MenuPage
public MenuPage ()
{
Title = "LoginPattern";
Icon = "slideout.png";
var section = new TableSection () {
new TextCell {Text = "Sessions"},
new TextCell {Text = "Speakers"},
new TextCell {Text = "Favorites"},
new TextCell {Text = "Room Plan"},
new TextCell {Text = "Map"},
};
var root = new TableRoot () {section} ;
tableView = new TableView ()
{
Root = root,
Intent = TableIntent.Menu,
};
var logoutButton = new Button { Text = "Logout" };
logoutButton.Clicked += (sender, e) => {
App.Current.Logout();
};
Content = new StackLayout {
BackgroundColor = Color.Gray,
VerticalOptions = LayoutOptions.FillAndExpand,
Children = {
tableView,
logoutButton
}
};
}
示例5: 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 }
};
}
示例6: Login
public Login()
{
Entry usuario = new Entry { Placeholder = "Usuario" };
Entry clave = new Entry { Placeholder = "Clave", IsPassword = true };
Button boton = new Button {
Text = "Login",
TextColor = Color.White,
BackgroundColor = Color.FromHex ("77D065")
};
boton.Clicked += (sender, e) => {
};
//Stacklayout permite apilar los controles verticalmente
StackLayout stackLayout = new StackLayout
{
Spacing = 20,
Padding = 50,
VerticalOptions = LayoutOptions.Center,
Children =
{
usuario,
clave,
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);
}
示例7: CreateControls
void CreateControls()
{
_picker = new DatePicker { Format = "D" };
_manExpense = new Entry { Placeholder = "Exemple : 0,00", Keyboard = Keyboard.Numeric };
_manExpense.TextChanged += numberEntry_TextChanged;
_womanExpense = new Entry { Placeholder = "Exemple : 0,00", Keyboard = Keyboard.Numeric };
_womanExpense.TextChanged += numberEntry_TextChanged;
_details = new Editor { BackgroundColor = AppColors.Gray.MultiplyAlpha(0.15d), HeightRequest = 150 };
Content = new StackLayout
{
Padding = new Thickness(20),
Spacing = 10,
Children =
{
new Label { Text = "Date" },
_picker,
new Label { Text = "Man expense" },
_manExpense,
new Label { Text = "Woman expense" },
_womanExpense,
new Label { Text = "Informations" },
_details
}
};
}
示例8: CreateMiddleLayout
static StackLayout CreateMiddleLayout()
{
// var preBlank = new Label {
// Text = "",
// FontSize = 11
// };
var preAbv = new Label {
Text = "Abv",
FontSize = 11,
FontAttributes = FontAttributes.Bold
};
var preIbu = new Label {
Text = "Ibu",
FontSize = 11,
FontAttributes = FontAttributes.Bold
};
var ctrlayout = new StackLayout()
{
//HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.Center,
Orientation = StackOrientation.Vertical,
Children = {preIbu, preAbv }
};
return ctrlayout;
}
示例9: MenuPage
public MenuPage ()
{
Icon = "settings.png";
Title = "Gráficos"; // The Title property must be set.
BackgroundColor = Color.FromHex ("333333");
Menu = new MenuListView ();
var menuLabel = new ContentView {
Padding = new Thickness (10, 36, 0, 5),
Content = new Label {
TextColor = Color.FromHex ("AAAAAA"),
Text = "Gráficos",
}
};
var layout = new StackLayout {
Spacing = 0,
VerticalOptions = LayoutOptions.FillAndExpand
};
layout.Children.Add (menuLabel);
layout.Children.Add (Menu);
Content = layout;
}
示例10: 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;
}
示例11: BookChapterLabel
public BookChapterLabel()
{
this.Orientation = StackOrientation.Horizontal;
this.HorizontalOptions = LayoutOptions.FillAndExpand;
this.VerticalOptions = LayoutOptions.StartAndExpand;
// Book & chapter layout
StackLayout bookChapter = new StackLayout
{
Orientation = StackOrientation.Horizontal,
Spacing = 0,
HorizontalOptions = LayoutOptions.CenterAndExpand
};
this.chapterLabel = new ChapterLabel();
bookChapter.Children.Add(chapterLabel);
this.bookLabel = new BookLabel();
bookChapter.Children.Add(this.bookLabel);
// Main layout
this.settingsLabel = new SettingsLabel();
this.Children.Add(this.settingsLabel);
this.Children.Add(bookChapter);
this.verseLabel = new VerseLabel();
this.Children.Add(this.verseLabel);
}
示例12: CreateNewCountLayout
public StackLayout CreateNewCountLayout()
{
var lblCount = new Label()
{
HorizontalOptions = LayoutOptions.Start,
FontSize = 24,
};
lblCount.SetBinding(Label.TextProperty, new Binding("Count" , stringFormat: "#{0}"));
var lblPrice = new Label()
{
HorizontalOptions = LayoutOptions.End,
FontSize = 24,
};
lblPrice.SetBinding(Label.TextProperty, new Binding("Price", stringFormat: "\t\t\t{0:C2}"));
var countLayout = new StackLayout()
{
HorizontalOptions = LayoutOptions.StartAndExpand,
Orientation = StackOrientation.Horizontal,
Children = { lblCount, lblPrice }
};
return countLayout;
}
示例13: RssFeedView2
public RssFeedView2()
{
this.viewModel = new RssFeedViewModel();
this.BindingContext = viewModel;
this.Title = "Rss Feed";
var refresh = new ToolbarItem(){ Command = viewModel.ReloadCommand, Name = "Reload", Priority = 0 };
ToolbarItems.Add(refresh);
var stack = new StackLayout(){ Orientation = StackOrientation.Vertical };
var activity = new ActivityIndicator(){ Color = Color.Blue, IsEnabled = true };
activity.SetBinding(ActivityIndicator.IsVisibleProperty, "ShowActivityIndicator");
activity.SetBinding(ActivityIndicator.IsRunningProperty, "ShowActivityIndicator");
stack.Children.Add(activity);
var listview = new ListView();
listview.ItemsSource = viewModel.Records;
var cell = new DataTemplate(typeof(ImageCell));
cell.SetBinding(ImageCell.TextProperty, "Title");
cell.SetBinding(ImageCell.ImageSourceProperty, "Image");
listview.ItemTemplate = cell;
listview.ItemSelected += async (sender, e) => {
await Navigation.PushAsync(new RssWebView((RssRecordViewModel)e.SelectedItem));
listview.SelectedItem = null;
};
stack.Children.Add(listview);
Content = stack;
}
示例14: RequiredFieldTriggerPage
public RequiredFieldTriggerPage ()
{
var l = new Label {
Text = "Entry requires length>0 before button is enabled",
};
l.FontSize = Device.GetNamedSize (NamedSize.Small, l);
var e = new Entry { Placeholder = "enter name" };
var b = new Button { Text = "Save",
HorizontalOptions = LayoutOptions.Center
};
b.FontSize = Device.GetNamedSize (NamedSize.Large ,b);
var dt = new DataTrigger (typeof(Button));
dt.Binding = new Binding ("Text.Length", BindingMode.Default, source: e);
dt.Value = 0;
dt.Setters.Add (new Setter { Property = Button.IsEnabledProperty, Value = false });
b.Triggers.Add (dt);
Content = new StackLayout {
Padding = new Thickness(0,20,0,0),
Children = {
l,
e,
b
}
};
}
示例15: TodoItemCell
public TodoItemCell ()
{
StyleId = "Cell";
var label = new Label {
StyleId = "CellLabel",
YAlign = TextAlignment.Center,
HorizontalOptions = LayoutOptions.StartAndExpand
};
label.SetBinding (Label.TextProperty, "Name");
var tick = new Image {
StyleId = "CellTick",
Source = FileImageSource.FromFile ("check"),
HorizontalOptions = LayoutOptions.End
};
tick.SetBinding (Image.IsVisibleProperty, "Done");
var layout = new StackLayout {
Padding = new Thickness(20, 0, 20, 0),
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.FillAndExpand,
Children = {label, tick}
};
View = layout;
}