Share via

LinearGradientBrush Have Problem in Xamarin.Forms 5 Update in Android

SimonGhost 256 Reputation points
2021-01-17T20:45:40.037+00:00

Hi, how are you Recently in Xamarin.Forms 5 update ,there is a problem in my Listview items its become transparent color when scroll down this problem happen just when i use LinearGradientBrush in my Frame and before this update I was not faced with this problem This is part of the code:

<ListView x:Name="Listview"  RowHeight="200">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell Height="300">
                            <Frame Margin="10,7,7,0" CornerRadius="5" HasShadow="True">
                                <Frame.Background>
                                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                                        <GradientStop Color="#0039AC" Offset="1.1"/>
                                        <GradientStop Color="#004CDD" Offset="1.0"/>
                                        <GradientStop Color="#3476FC" Offset="1.0"/>
                                    </LinearGradientBrush>
                                </Frame.Background>
                                <Grid>
                                <Label Text="{Binding Name}" TextColor="White" VerticalOptions="Start" HorizontalOptions="Center"></Label>
                                </Grid>
                            </Frame>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

this gif image:
43344.gif
and thanks for all :)

Developer technologies | .NET | Xamarin
0 comments No comments

Answer accepted by question author

JarvanZhang 23,971 Reputation points
2021-01-18T02:17:24.247+00:00

Hello,​

Welcome to our Microsoft Q&A platform!

This issue seems to be related to the caching of the listView, try setting CachingStrategy to RecycleElement or RecycleElementAndDataTemplate.

   <ListView x:Name="Listview" ItemsSource="{Binding dataList}" RowHeight="200" CachingStrategy="RecycleElement">  
       <ListView.ItemTemplate>  
           <DataTemplate>  
               ...  
           </DataTemplate>  
       </ListView.ItemTemplate>  
   </ListView>  

Best Regards,

Jarvan Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.