本文整理汇总了C#中Xamarin.Forms.Grid类的典型用法代码示例。如果您正苦于以下问题:C# Grid类的具体用法?C# Grid怎么用?C# Grid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Grid类属于Xamarin.Forms命名空间,在下文中一共展示了Grid类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OrderPageCode
public OrderPageCode ()
{
Title = "Order Page - Code";
var grid = new Grid {
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
Padding = new Thickness (15)
};
for (int x = 0; x < 7; x++) {
grid.RowDefinitions.Add (new RowDefinition{ Height = new GridLength(50) });
}
grid.ColumnDefinitions.Add (new ColumnDefinition{ Width = new GridLength(90) });
grid.ColumnDefinitions.Add (new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) });
grid.Children.Add (new Label { Text = "Purchaser's Name:" }, 0, 0);
grid.Children.Add (new Label { Text = "Billing Address:" }, 0, 1);
grid.Children.Add (new Label { Text = "Tip:", FontAttributes = FontAttributes.Bold }, 0, 2);
grid.Children.Add (new Label { Text = "Phone Number:" }, 0, 3);
grid.Children.Add (new Label { Text = "Comments:" }, 0, 4);
grid.Children.Add (new Entry { Placeholder = "Full Name on Card" }, 1, 0);
grid.Children.Add (new Editor (), 1, 1);
grid.Children.Add (new Entry{ Keyboard = Keyboard.Numeric }, 1, 2);
grid.Children.Add (new Entry { Keyboard = Keyboard.Telephone }, 1, 3);
grid.Children.Add (new Editor (), 1, 4);
var fstring = new FormattedString ();
fstring.Spans.Add (new Span { Text = "Wait! ", ForegroundColor = Color.Red });
fstring.Spans.Add (new Span { Text = "Please double check that everything is right." });
grid.Children.Add (new Label { FormattedText = fstring }, 1, 5);
grid.Children.Add (new Button { TextColor = Color.White, BackgroundColor = Color.Gray, Text = "Save" }, 1, 6);
Content = grid;
}
开发者ID:ChandrakanthBCK,项目名称:xamarin-forms-samples,代码行数:32,代码来源:OrderPageCode.cs
示例2: HomePageCS
public HomePageCS ()
{
var label = new Label {
Text = "Label Shadow Effect",
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
label.Behaviors.Add (new EffectBehavior {
Group = "Xamarin",
Name = "LabelShadowEffect"
});
Content = new Grid {
Padding = new Thickness (0, 20, 0, 0),
Children = {
new Label {
Text = "Effects Demo with a Behavior",
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Center
},
label
}
};
}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:25,代码来源:HomePageCS.cs
示例3: SliderLabels
private Grid SliderLabels()
{
var grid = new Grid {
HorizontalOptions = LayoutOptions.FillAndExpand,
ColumnDefinitions = {
new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
}
};
grid.Children.Add (
SyncLabel ("1", LayoutOptions.StartAndExpand, new Thickness (5, 0, 0, 0))
, 0, 0);
grid.Children.Add (
SyncLabel ("5", LayoutOptions.Center)
, 1, 0);
grid.Children.Add (
SyncLabel ("30", LayoutOptions.Center)
, 2, 0);
grid.Children.Add (
SyncLabel ("60", LayoutOptions.EndAndExpand, new Thickness (0, 0, 5, 0))
, 3, 0);
return grid;
}
开发者ID:QualityConsultingTeam,项目名称:ECanchaMobile,代码行数:30,代码来源:SyncSliderView.cs
示例4: FeedOverview
public FeedOverview()
{
var refreshButton = new Button {
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.Center,
Text = "Refresh"
};
refreshButton.SetBinding(Button.CommandProperty, "RefreshCommand");
var template = new DataTemplate(typeof(TextCell));
// We can set data bindings to our supplied objects.
template.SetBinding(TextCell.TextProperty, "Title");
template.SetBinding(TextCell.DetailProperty, "Description");
var listView = new ListView {ItemTemplate = template};
listView.SetBinding(ListView.ItemsSourceProperty, "FeedItems");
// Push the list view down below the status bar on iOS.
Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
Content = new Grid {
BindingContext = new FeedReaderViewModel(),
RowDefinitions = new RowDefinitionCollection {
new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
new RowDefinition { Height = new GridLength (0, GridUnitType.Auto) },
},
Children = {
new ViewWithGridPosition(listView, 0,0),
new ViewWithGridPosition(refreshButton, 1,0)
},
};
}
开发者ID:dotnetautor,项目名称:FeedReader2015,代码行数:33,代码来源:FeedOverview.cs
示例5: BaseAsyncActivityTemplate
public BaseAsyncActivityTemplate() {
// Adds the Content Presenter
var contentPresenter = new ContentPresenter();
Children.Add(contentPresenter, 0, 0);
// The overlay that is presented when an Activity is Running
var overlayGrid = new Grid { BackgroundColor = Color.FromHex("#CCCCCCCC") };
overlayGrid.SetBinding(IsVisibleProperty, new TemplateBinding("IsActivityRunning"));
var descriptionLabel = new Label { TextColor = Color.White };
descriptionLabel.SetBinding(Label.TextProperty, new TemplateBinding("ActivityDescription"));
var activityIndicator = new ActivityIndicator { Color = Color.White };
activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, new TemplateBinding("IsActivityRunning"));
// A layout to hold the Activity Indicator and Description
var activityIndicatorLayout = new StackLayout {
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
};
activityIndicatorLayout.Children.Add(activityIndicator);
activityIndicatorLayout.Children.Add(descriptionLabel);
// Finally add the indicator to the overlay and the overlay to the grid
overlayGrid.Children.Add(activityIndicatorLayout, 0, 0);
Children.Add(overlayGrid);
}
开发者ID:Caeno,项目名称:Lib-XamarinForms-Toolkit,代码行数:27,代码来源:BaseAsyncActivityContentPage.cs
示例6: GridPage5
public GridPage5 ()
{
Padding = new Thickness (0, Device.OnPlatform (20, 0, 0), 0, 0);
var grid = new Grid ();
grid.Children.Add (
new Image() {
Source= Device.OnPlatform("[email protected]", "icon.png", "")
}, 0, 0);
grid.Children.Add (new Label () { Text = "40", BackgroundColor = Color.Yellow}, 0, 1);
grid.Children.Add (new Label () { Text = "Remainder", BackgroundColor = Color.Pink}, 0, 2);
grid.RowDefinitions.Add (new RowDefinition ()
{
Height = new GridLength(1, GridUnitType.Auto)
});
grid.RowDefinitions.Add (new RowDefinition ()
{
Height = new GridLength(40, GridUnitType.Absolute)
});
grid.RowDefinitions.Add (new RowDefinition ()
{
Height = new GridLength(1, GridUnitType.Star)
});
Content = grid;
}
开发者ID:menoret-allan,项目名称:MyXamarinSamples,代码行数:30,代码来源:GridPage5.cs
示例7: GridLayoutPage
public GridLayoutPage()
{
var layout = new StackLayout
{
Orientation = StackOrientation.Vertical,
Padding = 20
};
var grid = new Grid
{
RowSpacing = 50
};
grid.Children.Add(new Label { Text = "This" }, 0, 0); // Left, First element
grid.Children.Add(new Label { Text = "text is" }, 1, 0); // Right, First element
grid.Children.Add(new Label { Text = "in a" }, 0, 1); // Left, Second element
grid.Children.Add(new Label { Text = "grid!" }, 1, 1); // Right, Second element
var gridButton = new Button { Text = "So is this Button!\nClick me." };
gridButton.Clicked += delegate
{
gridButton.Text = string.Format("Thanks! {0} clicks.", count++);
};
layout.Children.Add(grid);
layout.Children.Add (gridButton);
Content = layout;
}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:28,代码来源:GridLayoutPage.cs
示例8: OnAppearing
protected override void OnAppearing()
{
base.OnAppearing();
if (BindingContext == null)
{
BindingContext = _project;
var grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
grid.RowDefinitions.Add(new RowDefinition { Height = 150 });
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
grid.VerticalOptions = LayoutOptions.StartAndExpand;
grid.Children.Add(new Label { Text = "Name" }, 0, 0);
var editor = new Editor();
editor.SetBinding(Editor.TextProperty, "Name");
grid.Children.Add(editor, 1, 0);
label.IsVisible = false;
label.Text = "Error in value";
label.TextColor = Color.Red;
grid.Children.Add(label, 1, 1);
grid.Children.Add(new Label { Text = "Description" }, 0, 2);
grid.Children.Add(new Editor { Text = _project.Description }, 1, 2);
grid.Children.Add(new Label { Text = "Started" }, 0, 3);
grid.Children.Add(new Editor { Text = _project.Started.HasValue ? _project.Started.GetValueOrDefault().ToShortDateString() : string.Empty }, 1, 3);
grid.Children.Add(new Label { Text = "Ended" }, 0, 4);
grid.Children.Add(new Editor { Text = _project.Ended.HasValue ? _project.Ended.GetValueOrDefault().ToShortDateString() : string.Empty }, 1, 4);
Content = grid;
}
}
开发者ID:RodrigoGT,项目名称:csla,代码行数:32,代码来源:ProjectEdit.cs
示例9: HomePage
/// <summary>
/// Constructor
/// </summary>
public HomePage()
{
BackgroundImage = "bg.png";
var masterLayout = new StackLayout {
Orientation = StackOrientation.Vertical,
Spacing = 10
};
// Start Button
var startButton = new Button { Text = "スタート", HorizontalOptions = LayoutOptions.Center };
masterLayout.Children.Add(startButton);
// Text followed by two auto expanding text areas
var row = new StackLayout { Orientation = StackOrientation.Horizontal, Spacing = 10, Padding = new Thickness(10, 0, 10, 0) };
row.Children.Add(new Label { Text = "範囲:" });
masterLayout.Children.Add(row);
var grid = new Grid();
grid.HorizontalOptions = LayoutOptions.FillAndExpand;
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
var lowerBoundField = new Entry();
var upperBoundField = new Entry();
grid.Children.Add(lowerBoundField, 0, 0);
grid.Children.Add(upperBoundField, 1, 0);
row.Children.Add(grid);
// Data binding
upperBoundField.SetBinding(Entry.TextProperty, new Binding("UpperBoundText", BindingMode.TwoWay));
lowerBoundField.SetBinding(Entry.TextProperty, new Binding("LowerBoundText", BindingMode.TwoWay));
startButton.SetBinding(Button.CommandProperty, new Binding("StartPracticeCommand", BindingMode.OneWay));
Content = masterLayout;
}
开发者ID:borrrden,项目名称:SayNumbers,代码行数:36,代码来源:HomePage.cs
示例10: HomePageCS
public HomePageCS ()
{
label = new Label {
Text = "Label Shadow Effect",
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
ShadowEffect.SetHasShadow (label, true);
ShadowEffect.SetColor (label, Device.OnPlatform (Color.Black, Color.White, Color.White));
ShadowEffect.SetRadius (label, 5);
ShadowEffect.SetDistanceX (label, 5);
ShadowEffect.SetDistanceY (label, 5);
var button = new Button { Text = "Change Shadow Color", VerticalOptions = LayoutOptions.EndAndExpand };
button.Clicked += OnButtonClicked;
Content = new Grid {
Padding = new Thickness (0, 20, 0, 0),
Children = {
new Label {
Text = "Effects Demo",
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Center
},
label,
button
}
};
}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:30,代码来源:HomePageCS.cs
示例11: App
public App()
{
_grid = new Grid {
BackgroundColor = Color.Purple, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand
};
// THIS BOX VIEW DOES NOT SHOW UP IF YOU RE-SIZE THE ROW DEFINITION
var boxView = new BoxView { BackgroundColor = Color.Blue, VerticalOptions = LayoutOptions.End };
var button = new Button
{
Text = "button",
BackgroundColor = Color.Lime,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
button.Clicked += (sender, e) =>
{
_grid.RowDefinitions[1].Height = Math.Abs(_grid.RowDefinitions[1].Height.Value - 100) < double.Epsilon ?
new GridLength(0) : new GridLength(100);
};
Grid.SetRow(boxView, 1);
_grid.RowDefinitions.Add(new RowDefinition() { Height = 100 });
_grid.RowDefinitions.Add(new RowDefinition() { Height = 0 }); // CHANGE THIS TO 100 and it works fine
_grid.Children.Add(boxView);
_grid.Children.Add(button);
MainPage = new ContentPage { Content = _grid };
}
开发者ID:shanempope,项目名称:BoxViewGridRowIssue,代码行数:33,代码来源:BoxViewGridIssue.cs
示例12: GridExample2
public GridExample2 ()
{
Grid grid = new Grid
{
VerticalOptions = LayoutOptions.FillAndExpand,
//RowSpacing = 20,
//ColumnSpacing = 20,
RowDefinitions =
{
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = new GridLength(200, GridUnitType.Absolute) },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto }
},
ColumnDefinitions =
{
new ColumnDefinition { Width = GridLength.Auto },
new ColumnDefinition { Width = GridLength.Auto },
new ColumnDefinition { Width = GridLength.Auto }
}
};
grid.Children.Add(new Label
{
Text = "I'm at 0,0",
FontSize = 30,
FontAttributes = FontAttributes.Bold,
}, 0, 0);
grid.Children.Add(new Label
{
Text = "Me? 1, 1",
FontSize = 30,
FontAttributes = FontAttributes.Bold,
TextColor = Color.Black,
BackgroundColor = Color.Lime
}, 1, 1);
grid.Children.Add(new Label
{
Text = "2, 2 here",
FontSize = 25,
FontAttributes = FontAttributes.Bold,
TextColor = Color.White,
BackgroundColor = Color.Red
}, 2, 2);
grid.Children.Add(new Label
{
Text = "I'm at 0,3",
FontSize = 30,
FontAttributes = FontAttributes.Bold
}, 0, 3);
// Padding on edges and a bit more for iPhone top status bar
this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
this.Content = grid;
}
开发者ID:mhalkovitch,项目名称:Xamarim,代码行数:60,代码来源:GridExample2.cs
示例13: FlowListViewInternalCell
public FlowListViewInternalCell(FlowListView flowListView)
{
this.flowListView = flowListView;
root = new Grid() {
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
RowSpacing = 0f,
ColumnSpacing = 0f,
Padding = 0f,
RowDefinitions = new RowDefinitionCollection() {
new RowDefinition() { Height = GridLength.Auto }
},
ColumnDefinitions = new ColumnDefinitionCollection()
};
for (int i = 0; i < this.flowListView.FlowColumnsDefinitions.Count; i++)
{
root.ColumnDefinitions.Add(new ColumnDefinition() {
Width = new GridLength(1, GridUnitType.Star)
});
}
View = root;
}
开发者ID:rdelrosario,项目名称:DLToolkit.Forms.Controls,代码行数:25,代码来源:FlowListViewInternalCell.cs
示例14: FlowListViewInternalCell
/// <summary>
/// Initializes a new instance of the <see cref="DLToolkit.Forms.Controls.FlowListViewInternalCell"/> class.
/// </summary>
/// <param name="flowListViewRef">Flow list view reference.</param>
public FlowListViewInternalCell(WeakReference<FlowListView> flowListViewRef)
{
_flowListViewRef = flowListViewRef;
FlowListView flowListView = null;
flowListViewRef.TryGetTarget(out flowListView);
_useGridAsMainRoot = !flowListView.FlowUseAbsoluteLayoutInternally;
if (!_useGridAsMainRoot)
{
_rootLayout = new AbsoluteLayout()
{
Padding = 0d,
BackgroundColor = flowListView.FlowRowBackgroundColor,
};
View = _rootLayout;
}
else
{
_rootLayoutAuto = new Grid()
{
RowSpacing = 0d,
ColumnSpacing = 0d,
Padding = 0d,
BackgroundColor = flowListView.FlowRowBackgroundColor,
};
View = _rootLayoutAuto;
}
_flowColumnTemplate = flowListView.FlowColumnTemplate;
_desiredColumnCount = flowListView.DesiredColumnCount;
_flowColumnExpand = flowListView.FlowColumnExpand;
}
开发者ID:daniel-luberda,项目名称:DLToolkit.Forms.Controls,代码行数:36,代码来源:FlowListViewInternalCell.cs
示例15: LeagueCardView
public LeagueCardView(LeagueItem context)
{
BindingContext = context;
Grid grid = new Grid {
Padding = new Thickness(1,1,2,2),
RowSpacing = 0,
ColumnSpacing = 0,
BackgroundColor = Color.FromHex ("E3E3E3").MultiplyAlpha(0.5),
RowDefinitions = {
new RowDefinition { Height = new GridLength (100, GridUnitType.Absolute) }
},
ColumnDefinitions = {
new ColumnDefinition { Width = new GridLength (4, GridUnitType.Absolute) },
new ColumnDefinition {
}
}
};
grid.Children.Add (
new FixtureCardStatusView ()
,0,0);
grid.Children.Add (new LeagueCardDetailsView (LeagueItem), 1, 0);
var tgr = new TapGestureRecognizer { NumberOfTapsRequired = 1 };
tgr.Tapped += (sender, args) => {
OnCardClicked?.Invoke (LeagueItem);
};
grid.GestureRecognizers.Add (tgr);
Content = grid;
}
开发者ID:codnee,项目名称:Scores-App,代码行数:32,代码来源:LeagueCardView.cs
示例16: HomePageCS
public HomePageCS()
{
var label = new Label {
Text = "Label Shadow Effect",
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
label.Effects.Add (new ShadowEffect {
Radius = 5,
Color = Device.OnPlatform (Color.Black, Color.White, Color.Red),
DistanceX = 5,
DistanceY = 5
});
Content = new Grid {
Padding = new Thickness (0, 20, 0, 0),
Children = {
new Label {
Text = "Effects Demo",
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Center
},
label
}
};
}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:27,代码来源:HomePageCS.cs
示例17: GetBaseLayout
public BaseStackLayout GetBaseLayout()
{
var grid = new Grid
{
BackgroundColor = Color.White.ToFormsColor(),
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
RowDefinitions =
{
new RowDefinition { Height = GridLength.Auto }
},
ColumnDefinitions =
{
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }
}
};
grid.Children.Add (Drawer, 0, 1, 0, 1);
foreach (var layout in Layouts)
{
grid.Children.Add (layout, 1, 4, 0, 1);
}
var baseLayout = new BaseStackLayout
{
Children = { grid },
Padding = new Thickness(0)
};
return baseLayout;
}
开发者ID:jsnmgpnty,项目名称:Blogness2.0,代码行数:34,代码来源:DrawerLayout.cs
示例18: GenGrid
private Grid GenGrid()
{
var grid = new Grid();
grid.Children.Add(CreateButtonFor("Notifications", "Notify128.png", "1"), 0, 0);
grid.Children.Add(CreateButtonFor("Leave Balance", "Balance128.png", "2"), 1, 0);
return grid;
}
开发者ID:XnainA,项目名称:InsideInning,代码行数:7,代码来源:DashboardViewPage.cs
示例19: EditGateUser
public EditGateUser(GerenciarPortoesViewModel viewModel, GateDevices gateKey)
{
_viewModel = viewModel;
Grid grid = new Grid();
this.gateKey = gateKey;
string name = gateKey.SKeyName;
if (name.Length <= 4)
name = gateKey.SkeyBleId;
Title = "Editar " + name;
removerUserGate.AnimateWithAction();
removerUserGate.Clicked += removerUserGate_Clicked;
grid.Children.AddVertical(listProfileDisponiveis);
grid.Children.Add(removerUserGate);
listProfileDisponiveis.ItemTapped += listProfileDisponiveis_ItemTapped;
var absoluteLayout = new AbsoluteLayout();
var background = new Image
{
Style = Styles.BackgroundImage
};
absoluteLayout.Children.Add(background, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All);
absoluteLayout.Children.Add(grid, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All);
Content = absoluteLayout;
}
开发者ID:RobertoOFonseca,项目名称:MySafety,代码行数:31,代码来源:EditGateUser.cs
示例20: GenLowerGrid
private Grid GenLowerGrid()
{
var grid = new Grid();
grid.Children.Add(CreateButtonFor("Employee Details", "Employee128.png", "3"), 0, 0);
grid.Children.Add(CreateButtonFor("Leave Details", "NotePad128.png", "4"), 1, 0);
return grid;
}
开发者ID:XnainA,项目名称:InsideInning,代码行数:7,代码来源:DashboardViewPage.cs
注:本文中的Xamarin.Forms.Grid类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论