每个人的好日子,我有网格有4列我想合并第2列和第3列,如下图所示,但问题是每个条目都分配给特定的Grid.Column。我该如何实现这一目标?谢谢你,祝你好日子。 我的Xaml代码:
<ContentView Grid.Row="0" HorizontalOptions="StartAndExpand" Padding="10" VerticalOptions="CenterAndExpand">
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0"
Grid.Row="0"
Grid.RowSpan="2"
Source="contact.png"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"
/>
<Label Grid.Row="0"
Grid.Column="1"
FontAttributes="Bold"
HorizontalOptions="Start"
Text="Number:"
TextColor="White"
VerticalOptions="Center"/>
<Label Grid.Row="1"
Grid.Column="1"
FontAttributes="Bold"
HorizontalOptions="Start"
Text="Name:"
TextColor="White"
VerticalOptions="Center"/>
<Entry Grid.Row="0"
Grid.Column="2"
FontAttributes="Bold"
IsEnabled="False"
HorizontalOptions="Start"
Text="911"
TextColor="White"
VerticalOptions="Center"/>
<Entry Grid.Row="1"
Grid.Column="2"
IsEnabled="False"
FontAttributes="Bold"
HorizontalOptions="Start"
Text="Andreson Smith"
TextColor="White"
VerticalOptions="Center"/>
</Grid>
</ContentView>
答案 0 :(得分:4)
您想要在要占用多列的元素上设置Grid.ColumnSpan:
<Entry Grid.Row="0"
Grid.Column="2"
Grid.ColumnSpan="2"
FontAttributes="Bold"
IsEnabled="False"
HorizontalOptions="Start"
Text="911"
TextColor="White"
VerticalOptions="Center"/>
此条目将从第2列和第2列开始,因此“合并”第2列和第3列。