【发布时间】:2017-12-31 03:27:08
【问题描述】:
我有以下对象:
new Grid {
RowDefinitions =
{
new RowDefinition { Height = new GridLength(3, GridUnitType.Star) },
new RowDefinition { Height = new GridLength(2, GridUnitType.Star) },
new RowDefinition { Height = new GridLength(2, GridUnitType.Star) }
},
ColumnDefinitions =
{
new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }
},
Children =
{
new Label { Text = "TRIP #5", FontFamily = Device.OnPlatform(null, "latoblack.ttf#Lato Black", null), FontSize = 16, TextColor = Color.White, HorizontalTextAlignment = TextAlignment.Start, Margin = new Thickness(0, 0, 0, 10) },
new Label { Text = "Started 24/07/2017", FontFamily = Device.OnPlatform(null, "latolight.ttf#Lato Light", null), FontSize = 16, TextColor = Color.White, HorizontalTextAlignment = TextAlignment.Start },
new Label { Text = "Is currently in progress", FontFamily = Device.OnPlatform(null, "latolight.ttf#Lato Light", null), FontSize = 16, TextColor = Color.White, HorizontalTextAlignment = TextAlignment.Start }
}
}
我想将标签放置在 (0,0)、(0,1)、(1,1) 位置,而不必使用 Children.Add。更具体地说,我想将标签的位置设置为我直接从对象定义中提到的位置。我该怎么做?
提前谢谢你!
【问题讨论】:
-
它没有回答我的问题。我正在尝试设置位置,而不必使用 Grid 对象之外的任何函数。
-
那有什么好处呢?
标签: c# xamarin xamarin.forms