本文整理汇总了C#中Xamarin.Forms.Grid.SetGridProperties方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.SetGridProperties方法的具体用法?C# Grid.SetGridProperties怎么用?C# Grid.SetGridProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xamarin.Forms.Grid
的用法示例。
在下文中一共展示了Grid.SetGridProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SimplePushAlertView
public SimplePushAlertView()
{
RowDefinitions = new RowDefinitionCollection
{
new RowDefinition {Height = new GridLength(1, GridUnitType.Auto)}
};
// Allow taps to pass through
InputTransparent = true;
if (Device.Idiom == TargetIdiom.Phone)
{
ColumnDefinitions = new ColumnDefinitionCollection
{
// Content
new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)},
};
}
else
{
ColumnDefinitions = new ColumnDefinitionCollection
{
// Spacer
new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)},
// Content
new ColumnDefinition {Width = new GridLength(1, GridUnitType.Auto)},
// Spacer
new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)},
};
}
_contentGrid = new Grid
{
RowDefinitions = new RowDefinitionCollection
{
new RowDefinition {Height = new GridLength(1, GridUnitType.Auto)},
new RowDefinition {Height = new GridLength(1, GridUnitType.Auto)},
new RowDefinition {Height = new GridLength(1, GridUnitType.Auto)}
},
ColumnDefinitions = new ColumnDefinitionCollection
{
new ColumnDefinition {Width = new GridLength(1, GridUnitType.Auto)},
new ColumnDefinition {Width = new GridLength(1, GridUnitType.Auto)}
},
BackgroundColor = Color.Teal,
InputTransparent = InputTransparent
};
// No spacers needed on phone
_contentGrid.SetGridProperties(0, Device.Idiom == TargetIdiom.Phone ? 0 : 1);
Children.Add(_contentGrid);
_image = new Image
{
HeightRequest = 32,
WidthRequest = 32,
InputTransparent = InputTransparent
};
_contentGrid.Children.Add(_image
.WithPadding(10)
.SetGridProperties(0, 0, 2));
_titleLabel = new Label
{
TextColor = Color.White,
FontSize = 16,
InputTransparent = InputTransparent
};
_contentGrid.Children.Add(_titleLabel
.WithPadding(10, 10, 0, 0)
.SetGridProperties(0, 1));
_bodyLabel = new Label
{
TextColor = Color.White,
FontSize = 12,
WidthRequest = 320,
InputTransparent = InputTransparent
};
_contentGrid.Children.Add(_bodyLabel
.WithPadding(0, 10, 0, 0)
.SetGridProperties(1, 1));
}
示例2: AddActionButtons
public void AddActionButtons(string label1, Action callback1, string label2, Action callback2)
{
var button1 = CreateButton(label1, callback1);
var button2 = CreateButton(label2, callback2);
var buttonContainer = new Grid
{
RowDefinitions = new RowDefinitionCollection
{
new RowDefinition {Height = new GridLength(1, GridUnitType.Auto)}
},
ColumnDefinitions = new ColumnDefinitionCollection
{
new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)},
new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)}
}
};
buttonContainer.SetGridProperties(2, columnSpan: 2);
ContentGrid.Children.Add(buttonContainer);
// Button 2 should be on the left, button 1 on the right
buttonContainer.Children.Add(button2
.WithPadding(5)
.SetGridProperties(0, 0));
buttonContainer.Children.Add(button1
.WithPadding(5)
.SetGridProperties(0, 1));
}