C# listview项目滚动时的文本更改

C# listview项目滚动时的文本更改,c#,listview,xamarin,xamarin.forms,listviewitem,C#,Listview,Xamarin,Xamarin.forms,Listviewitem,我有一个列表视图,其中我绑定了多个数据,如标签和图像,我的框架中有该列表,因此当列表大小超过10个项目左右时,滚动我的图像会自行调整大小,标签文本开始隐藏 这是我的xaml: <ListView x:Name="list" SelectionMode="None" Separ

我有一个列表视图,其中我绑定了多个数据,如标签和图像,我的框架中有该列表,因此当列表大小超过10个项目左右时,滚动我的图像会自行调整大小,标签文本开始隐藏

这是我的xaml:

            <ListView 
                               x:Name="list" 
                               SelectionMode="None" 

                               SeparatorVisibility="None"
                               HasUnevenRows="True"
                               IsVisible="False"
                               BackgroundColor="Transparent"
                               ItemTapped="List_ItemTapped"
                               CachingStrategy="RetainElement"
                              >
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <ViewCell>
                                            <Frame Padding="10" Margin="10">

                                                <Grid>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition 
        Height="Auto" />
                                                        <RowDefinition Height="*" 
        />
                                                    </Grid.RowDefinitions>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition 
        Width="Auto" />
                                                        <ColumnDefinition 
        Width="*" />
                                                    </Grid.ColumnDefinitions>
                                                    <Label 
                                                        Grid.Row="0" 
                                                        Grid.Column="0"

                                                        Text="{Binding Note}" 
                                                        HorizontalOptions="Start"  
                                                        TextColor="Black"  
        FontSize="Small"
                                                        FontFamily=" 
       {StaticResource BoldFont}"
                                                        FontAttributes="Bold">
                                                    </Label>
                                                    <ImageButton
                                                         Grid.Row="0"  
                                                         Grid.Column="1"


        HorizontalOptions="EndAndExpand"
                                                        WidthRequest="22"
                                                        HeightRequest="22"
                                                        Padding="6"
                                                        Margin="0,0,0,0"
                                                        Clicked="btndelete"

        AbsoluteLayout.LayoutBounds="0,0,1,1"

        BackgroundColor="Transparent"
                                                        Source="close.png">
                                                    </ImageButton>
                                                    <Label 
                                                            Grid.Row="1"  
                                                            Grid.Column="0"

                                                            Text="{Binding 
        NOfQuestions}"
                                                            FontSize="12"
                                                            FontFamily=" 
       {StaticResource Regular}"
                                                            TextColor="White">

                                                    </Label>
                                                    <Label 
                                                            Grid.Row="1"  
                                                            Grid.Column="0"
                                                            Margin="15,0,0,0"

                                                            Text="{Binding 
        NOfDigits}"
                                                            FontSize="12"
                                                            FontFamily=" 
       {StaticResource Regular}"
                                                            TextColor="White">

                                                    </Label>
                                                </Grid>

                                            </Frame>
        </ViewCell>

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

这是我的问题的视频在这个视频中你可以看到列表看起来不错,但是当我开始滚动它时,文本开始隐藏,取消隐藏它的大小更改,交叉图像变小或变大,删除列表项时,所有文本都消失了

试试这个

                 <ListView 
                       x:Name="list" 
                       SelectionMode="None" 
                       HorizontalOptions="FillAndExpand"
                       VerticalOptions="FillAndExpand"
                       SeparatorVisibility="None"
                       HasUnevenRows="True"                     
                       BackgroundColor="Transparent"
                       CachingStrategy="RetainElement"
                      >
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Frame Padding="10" Margin="10">

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition 
                                 Height="Auto" />
                                <RowDefinition Height="Auto" 
                                        />
                            </Grid.RowDefinitions>
                            <StackLayout Grid.Row="0" Orientation="Horizontal" HorizontalOptions="FillAndExpand" >


                                <Label                                                         
                                                Text="{Binding Note}" 
                                                HorizontalOptions="StartAndExpand"  
                                                TextColor="Black"  
                                                FontSize="Small"
                                                FontFamily=" 
                                                {StaticResource BoldFont}"
                                                FontAttributes="Bold">
                                </Label>
                            <ImageButton
                                          
                                                 HorizontalOptions="EndAndExpand"
                                                 WidthRequest="22"
                                                 HeightRequest="22"
                                                 Padding="6"
                                                 Margin="0,0,0,0"
                                                 Clicked="btndelete"  
                                                 AbsoluteLayout.LayoutBounds="0,0,1,1"    
                                                 BackgroundColor="Transparent"
                                                Source="close.png">
                            </ImageButton>




                            </StackLayout>
                            
 

                            <StackLayout Grid.Row="1" Orientation="Horizontal" HorizontalOptions="FillAndExpand">
                                <Label 
                                                    
                                                    Text="{Binding 
                                                    NOfQuestions}"
                                                    HorizontalOptions="StartAndExpand" 
                                                    FontSize="12"
                                                    FontFamily=" 
                                                    {StaticResource Regular}"
                                                    TextColor="White">

                                </Label>
                                <Label 
                                                  
                                                    Margin="15,0,0,0"    
                                                    Text="{Binding 
                                                    NOfDigits}"
                                                    HorizontalOptions="CenterAndExpand"
                                                    FontSize="12"
                                                    FontFamily=" 
                                                   {StaticResource Regular}"
                                                    TextColor="White">

                                </Label>
                            </StackLayout>
                
                        </Grid>

                    </Frame>
                </ViewCell>

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

这种重新呈现列表单元格的行为通常与
列表视图
缓存策略有关。它定义了单元格的缓存方式,并试图在加载大量数据时提高性能,但也会影响正确的显示。试着把
CachingStrategy
搞砸。根据以往的经验,将其设置为“RecycleElement”可以解决渲染问题


另外,请查看有关ListView性能的更多信息。

当您在
ListView中有自定义单元格时,建议使用
CachingStrategy

ListView
是显示数据的强大视图,但它有一些局限性。使用自定义单元格时,滚动性能可能会受到影响,尤其是当它们包含深度嵌套的视图层次结构或使用某些需要复杂度量的布局时

XAML for Xamarin.Forms为与缓存策略参数相对应的不存在属性提供XAML属性:

<ListView CachingStrategy="RecycleElement" >
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <!-- ... -->
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>


仍然存在相同的问题仍然存在相同的问题能否将RowDefensions更改为一些固定值?如果我们使用一个标签创建一个简单列表,同样的问题也会再次出现在简单列表中。您是否在listview之前添加了scrollview?您是否已经解决了这个问题?我也有类似的问题。