我正在处理的应用程序已将堆栈元素放置在网格中并对其应用填充:
<Grid x:Name="detailGrid" Grid.Row="1" Grid.Column="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackLayout Grid.Row="0" Grid.Column="0" Padding="10,0,10,0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Label x:Name="detail1" FontSize="35" XAlign="Center" VerticalOptions="Center" LineBreakMode="WordWrap" />
</StackLayout>
<StackLayout Grid.Row="1" Grid.Column="0" Padding="10,0,10,0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Label x:Name="detail2" FontSize="35" XAlign="Center" VerticalOptions="Center" LineBreakMode="WordWrap" />
</StackLayout>
<StackLayout Grid.Row="2" Grid.Column="0" Padding="10,0,10,0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Label x:Name="detail3" FontSize="35" XAlign="Center" VerticalOptions="Center" LineBreakMode="WordWrap" />
</StackLayout>
</Grid>
是否可以消除Stacklayout并将其应用于标签本身?
答案 0 :(得分:1)
请尝试下面的代码我删除了所有不必要的代码。
<Grid x:Name="detailGrid" Grid.Row="1" Grid.Column="0" Padding="10,0,10,0" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label x:Name="detail1" Grid.Row="0" FontSize="35" XAlign="Center" VerticalOptions="Center" LineBreakMode="WordWrap" />
<Label x:Name="detail2" Grid.Row="1" FontSize="35" XAlign="Center" VerticalOptions="Center" LineBreakMode="WordWrap" />
<Label x:Name="detail3" Grid.Row="2" FontSize="35" XAlign="Center" VerticalOptions="Center" LineBreakMode="WordWrap" />
</Grid>
答案 1 :(得分:0)
有RowSpacing
和ColumnSpacing
等属性。
在您的情况下,您想要左右边距应用保证金吗?那就是
<Grid ColumnSpacing="10">