我试图在listview(带有列的模板)中使用boxview控件绘制类似小条形图的东西。因此,在每个项目的一列中,我想绘制具有可变高度的boxview(取决于变量值)
这样的事情:
<ListView x:Name="lstView" RowHeight="75">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell >
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Text="{Binding Local}" VerticalTextAlignment="End" HorizontalTextAlignment="Center" Grid.Row="0" Grid.Column="1" FontSize="10" TextColor="Navy" />
<Label Text="Empate" Grid.Row="0" VerticalTextAlignment="End" HorizontalTextAlignment="Center" Grid.Column="3" FontSize="10" TextColor="Navy"/>
<Label Text="{Binding Visitante}" VerticalTextAlignment="End" HorizontalTextAlignment="Center" Grid.Row="0" Grid.Column="5" FontSize="10" TextColor="Navy"/>
**<BoxView Grid.Row="0" Grid.Column="5" HeightRequest="{Binding PctLocal}" WidthRequest="15"/>;**
<Label Text="{Binding PctEmpate}" VerticalTextAlignment="End" HorizontalTextAlignment="Center" Grid.Row="0" Grid.Column="2" FontSize="10" />
<Label Text="{Binding PctVisitante}" VerticalTextAlignment="End" HorizontalTextAlignment="Center" Grid.Row="0" Grid.Column="4" FontSize="10" />
<Label Text="{Binding LocalSupporters}" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Grid.ColumnSpan="2" Grid.Row="1" Grid.Column="0" FontSize="10" />
<Label Text="{Binding DrawSupporters}" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" FontSize="10" />
<Label Text="{Binding AwaySupporters}" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Grid.Row="1" Grid.Column="4" Grid.ColumnSpan="2" FontSize="10" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我怎样才能做到这一点?