小编wal*_*an1的帖子

如何在XAML中自动调整列表视图的高度

我的列表视图对象接收图像,ID号和概要.概要的大小不同,因为有些人有空白回报.我注意到ListView有一个我可以设置的行高(我现在设置为250),但它只能是一个固定值.所以会发生什么,我的网格对于ListView来说变得太高了,导致它溢出并覆盖到下一个列出的项目上.无论如何在XAML中自动调整列表视图的大小?

<ListView ItemsSource="{Binding List}" VerticalOptions="FillAndExpand" RowHeight="250" SelectedItem="SelectedCTR" SeparatorVisibility="None">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Image Grid.Row="0" HeightRequest="100" MinimumWidthRequest="160" WidthRequest="160" Source="{Binding AttachedmentData,Converter={StaticResource stringToImage}}" />
                    <StackLayout Grid.Row="1" VerticalOptions="FillAndExpand">
                        <Label Text="{Binding Number}" Font="19"
                             TextColor="#f35e20" />
                        <Label Text="{Binding TrimmedSynopsis}" Font="17"
                             TextColor="#503026" />
                    </StackLayout>
                </Grid>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>
Run Code Online (Sandbox Code Playgroud)

c# xaml visual-studio ios xamarin

4
推荐指数
2
解决办法
6253
查看次数

标签 统计

c# ×1

ios ×1

visual-studio ×1

xamarin ×1

xaml ×1