xamarin.forms - Xamarin Forms:网格增加单个自动换行上所有行的行高
问题描述
在我的 Xamarin Forms 视图中,当网格中的一行有自动换行时,它也会增加所有其他行的行高。我可以更改哪些属性以确保只有受影响的行增加了行高?
普通造型:
在“位置”上包装后的样式:
XAML:
<ScrollView>
<StackLayout Padding="10" x:DataType="auctions:VehicleViewModel">
<ActivityIndicator x:Name="ActivitySpinner" IsRunning="True" IsVisible="{Binding IsBusy}" />
<Label Text="{Binding Error}" StyleClass="Error" IsVisible="{Binding ErrorVisible}" />
<Label Text="Basic Details" StyleClass="HeaderGreen" IsVisible="{Binding IsNotBusy}" />
<Grid IsVisible="{Binding IsNotBusy}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Text="Model" StyleClass="Label" Grid.Column="0" Grid.Row="0" />
<Label Text="{Binding Vehicle.VehicleModel}" Grid.Column="1" Grid.Row="0" />
<Label Text="Registration" StyleClass="Label" Grid.Column="0" Grid.Row="1" />
<Label Text="{Binding Vehicle.Registration}" Grid.Column="1" Grid.Row="1" />
<Label Text="Year" StyleClass="Label" Grid.Column="0" Grid.Row="2" />
<Label Text="{Binding Vehicle.Year}" Grid.Column="1" Grid.Row="2" />
<Label Text="Mileage (Kms)" StyleClass="Label" Grid.Column="0" Grid.Row="3" />
<Label Text="{Binding Vehicle.Odometer}" Grid.Column="1" Grid.Row="3" />
<Label Text="Supplier" StyleClass="Label" Grid.Column="0" Grid.Row="4" />
<Label Text="{Binding Vehicle.Supplier}" Grid.Column="1" Grid.Row="4" />
<Label Text="Location" StyleClass="Label" Grid.Column="0" Grid.Row="5" />
<Label Text="{Binding Vehicle.Location}" Grid.Column="1" Grid.Row="5" />
<Label Text="Gearbox" StyleClass="Label" Grid.Column="0" Grid.Row="6" />
<Label Text="{Binding Vehicle.GearboxType}" Grid.Column="1" Grid.Row="6" />
<Label Text="Colour" StyleClass="Label" Grid.Column="0" Grid.Row="7" />
<Label Text="{Binding Vehicle.Colour}" Grid.Column="1" Grid.Row="7" />
<Label Text="Interior Colour" StyleClass="Label" Grid.Column="0" Grid.Row="8" />
<Label Text="{Binding Vehicle.InteriorColour}" Grid.Column="1" Grid.Row="8" />
<Label Text="Financed By" StyleClass="Label" Grid.Column="0" Grid.Row="9" />
<Label Text="{Binding Vehicle.FinancedBy}" Grid.Column="1" Grid.Row="9" />
<Label Text="Trade Price" StyleClass="Label" Grid.Column="0" Grid.Row="10" />
<Label Text="{Binding Vehicle.TradePrice, Converter={StaticResource Currency}}" Grid.Column="1" Grid.Row="10" />
<Label Text="Retail Price" StyleClass="Label" Grid.Column="0" Grid.Row="11" />
<Label Text="{Binding Vehicle.RetailPrice, Converter={StaticResource Currency}}" Grid.Column="1" Grid.Row="11" />
<Label Text="New Price" StyleClass="Label" Grid.Column="0" Grid.Row="12" />
<Label Text="{Binding Vehicle.NewPrice, Converter={StaticResource Currency}}" Grid.Column="1" Grid.Row="12" />
</Grid>
解决方案
尝试定义Auto
高度:
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
这是Xamarin.Forms Grid 的文档,请检查行和列段落。如文档中所述,您应尽量确保将尽可能少的行设置为自动大小。因此,仅将其用于受影响的行。
推荐阅读
- java - JVM 的堆大小不断增加(但 usedMemory() 不断减少)
- python - 混淆更改日期时间的时区
- cordova - 我无法将 app-debug.apk 安装到我的手机中
- rust - 为什么选择日期时间
不能满足serde::Serialize? - sql - 将表(列)值转换为独立行
- c# - 需要使用一个文件来填充一个数组,然后是一个列表框。我设法让它充满了一些东西,但我无法让它正确显示。建议?
- python - Travis CI 在 macOS 上找不到 python3
- tensorflow - TF 2.0 中的模型和一堆堆叠层有什么区别?
- rust - 从 csv 文件解析 50 位整数: ParseIntError { kind: Overflow }
- mysql - 使用 JPA 从 mysql 中的数据库访问 3 个表,springboot 为 json 键格式