我在网格中有2行。在第一行中,我有5列,在每一列中,我都有一个文本块。在第二行中,我有一个分隔线。 我可以包装最后一个文本块,使其从网格的第二行开始吗? 目前,这是我的xaml代码。
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding FullName}" Grid.Row="0" Grid.Column="0" x:Name="firstName" Visibility="{Binding FullName, Converter={StaticResource NullOrWhiteSpaceConverter}}" TextAlignment="Left"/>
<TextBlock Text=" | " FontWeight="Bold" Foreground="#008DFC" Grid.Column="1" Grid.Row="0" Margin="0,0,0,0" Visibility="{Binding Visibility,ElementName=firstlevel}" HorizontalAlignment="Left"/>
<TextBlock Text="{Binding FirstLevelParent}" Grid.Row="0" Margin="10,0,0,0" Visibility="{Binding FirstLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" x:Name="firstlevel" Grid.Column="1" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="1" Grid.Row="0" Visibility="{Binding Visibility,ElementName=middleName}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding SecondLevelParent}" Grid.Row="0" Margin="10,0,0,0" Visibility="{Binding SecondLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" x:Name="middleName" Grid.Column="2" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="2" Grid.Row="0" Visibility="{Binding Visibility,ElementName=lastName}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding ThreeLevelParent}" Grid.Row="0" Margin="10,0,0,0" x:Name="lastName" Visibility="{Binding ThreeLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" Grid.Column="3" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="3" Grid.Row="0" Visibility="{Binding Visibility,ElementName=fourlevel}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding FourLevelParent}" TextWrapping="Wrap" Grid.Row="0" Margin="10,0,0,0" x:Name="fourlevel" Visibility="{Binding FourLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" Grid.Column="4" TextAlignment="Left"/>
<Grid Grid.Row="1" x:Name="deliverypoint" Visibility="Collapsed">
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>-->
<TextBlock Text="{Binding DeliveryPoint}" x:Name="deliverypointname" TextAlignment="Left" Foreground="Black" FontSize="12"/>
</Grid>
<!--<TextBlock Text="|" Grid.Column="2" Margin="0,0,-6,0" Visibility="{Binding Visibility,ElementName=lastName}" HorizontalAlignment="Right"/>-->
</Grid>
<TextBlock TextWrapping="NoWrap" Text="-------------------------------------------------------------------------" Grid.Row="1"/>
</Grid>
答案 0 :(得分:0)
我建议您不要使用“ Grid.ColumnDefinition”来布局TextBlock。相反,您可以使用WrapPanel XAML Control包装这些TextBlock。达到最大宽度或高度后,控件会根据方向自动创建行或列。
我制作了一个简单的代码示例供您参考:
:%s/\*\/5 \* \* \* \*//
:%s#\V*/5 * * * *##