简体   繁体   English

Xamarin.Forms ListView在滚动后更改集合之前在Android中呈现错误

[英]Xamarin.Forms ListView renders wrong in Android after scrolling before collection is changed

If I simply modify the ListView's data without scrolling, everything displays correctly: 如果我只是简单地修改了ListView的数据而不滚动,则所有内容都会正确显示:

https://gfycat.com/illustriousnastyconey https://gfycat.com/illustriousnastyconey

However, if I scroll before changing the data, everything looks broken after the data changes: 但是,如果我在更改数据之前滚动,则数据更改后一切看起来都坏了:

https://gfycat.com/abandonedvelvetyaoudad https://gfycat.com/abandonedvelvetyaoudad

Here is my ListView XAML 这是我的ListView XAML

<ListView ItemsSource="{Binding network.Predictions}" x:Name="ShowsList" IsGroupingEnabled="True" HasUnevenRows="True" ItemTapped="ShowsList_ItemTapped">
        <ListView.GroupHeaderTemplate>
            <DataTemplate>
                <ViewCell Height="25">
                    <Grid BackgroundColor="#CC778899">
                        <Label Text="{Binding Category}" FontSize="Small" TextColor="White" VerticalOptions="Center" Margin="5,0,0,0"/>
                    </Grid>                        
                </ViewCell>
            </DataTemplate>
        </ListView.GroupHeaderTemplate>

        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Grid BackgroundColor="White">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <Label Text="{Binding Name}" FontSize="Medium" Margin="5"/>
                        <Label Grid.Column="1" Text="{Binding Status}" FontSize="Small" TextColor="{Binding StatusIndex, Converter={StaticResource StatusColor}}" Margin="5" VerticalOptions="Center/>
                    </Grid>

                </ViewCell>                    
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

Also, after this happens, if I scroll so that the messed up elements go off screen, and then scroll back, those elements appear just fine. 另外,在发生这种情况之后,如果我滚动以使混乱的元素离开屏幕,然后再向后滚动,则这些元素看起来就很好。 It does appear to be allocating the space correctly, and they appear correctly after scrolling, so it's not reading the data incorrectly or anything like that, it's just not displaying correctly. 它的确似乎在正确分配空间,并且在滚动后它们正确地显示,因此它不是在错误地读取数据或类似的东西,只是在显示不正确。

I had an idea and changed the background color of the listview to red to see if maybe the text was rendering as white, but nope, those missing elements are fully transparent. 我有个主意,将listview的背景颜色更改为红色,以查看文本是否呈现为白色,但是不,那些丢失的元素是完全透明的。 The correct elements all have a background color, but the missing elements just showed as red. 正确的元素都具有背景色,但是缺少的元素仅显示为红色。

它似乎是listview的错误,此问题存在于3.6的初始版本中,并且已在3.6.0.344457中进行了修复,许多开发人员都遇到此问题,如果您有类似的问题,请查看: https://github.com。 com / xamarin / Xamarin.Forms / pull / 6390以及最快速,最轻松的解决方法是将Xamarin.Forms版本回滚

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM