亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

滾動時列表視圖項目文本發生變化

滾動時列表視圖項目文本發生變化

C#
慕工程0101907 2023-06-25 13:53:41
我有一個列表視圖,其中綁定了標簽和圖像等多個數據,并且我的框架中有該列表,因此當列表大小大于 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="*" />當我開始滾動它時,文本開始隱藏,取消隱藏其大小變化,十字圖像變小或變大,并且在刪除列表項時,所有文字消失
查看完整描述

3 回答

?
慕少森

TA貢獻2019條經驗 獲得超9個贊

這種重新渲染列表單元格的行為通常與ListView緩存策略有關。它定義了單元格的緩存方式,并嘗試在加載大量數據時提高性能,但也可能會影響正確的顯示。嘗試搞亂CachingStrategy.?根據過去的經驗,將其設置為“RecycleElement”可以解決渲染問題。


查看完整回答
反對 回復 2023-06-25
?
皈依舞

TA貢獻1851條經驗 獲得超3個贊

嘗試這個


                 <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>



查看完整回答
反對 回復 2023-06-25
?
縹緲止盈

TA貢獻2041條經驗 獲得超4個贊

當您在 a 中有自定義單元格時,ListView建議使用CachingStrategy


ListView是顯示數據的強大視圖,但它有一些局限性。使用自定義單元格時,滾動性能可能會受到影響,特別是當它們包含深度嵌套的視圖層次結構或使用需要復雜測量的某些布局時。


Xamarin.Forms 的 XAML 為與緩存策略參數對應的不存在的屬性提供 XAML 屬性:


<ListView CachingStrategy="RecycleElement" >

    <ListView.ItemTemplate>

        <DataTemplate>

            <ViewCell>

                <!-- ... -->

            </ViewCell>

        </DataTemplate>

    </ListView.ItemTemplate>

</ListView>


查看完整回答
反對 回復 2023-06-25
  • 3 回答
  • 0 關注
  • 136 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號