As the code shows below, I did bind a label to the myViewModel's string LabelInfo. When I receive the data in scrollview, everything shows fine on Android and iOS. But on Android when I scroll down or up until the label is not shown and then I scroll back again, the label text is dissapeard and it appears again when I bring the phone keyboard up again by pressing a searchBar above the listview. Is there a way to force showing/rendering the label text?
<ListView.ItemTemplate >
<Grid.ColumnDefinitions >
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
</Grid.RowDefinitions> .......... <StackLayout Grid.Column="3" Grid.Row="1" Orientation="Vertical"> <Label Text="{Binding UserName}" FontSize="15" FontAttributes="Bold" TextColor="#474747" VerticalOptions="Center" FontFamily="{StaticResource EncodeSansSemiCondensed-Bold}"/> <StackLayout Padding="0" Orientation="Horizontal"> //the labelinfo text dissapears when outside listview <Label Text="{Binding LabelInfo}" TextDecorations="Underline" TextColor="#3366BB" LineBreakMode="TailTruncation" FontFamily="{StaticResource EncodeSansSemiCondensed-Bold}" FontSize="10"> <Label.GestureRecognizers> <TapGestureRecognizer Tapped="ShowCompToastInfo" /> </Label.GestureRecognizers> </Label> </StackLayout> </StackLayout> ......... </Grid> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate>
Posts
Try CollectionView
the collectionview does not have the properties below that the listview has and also i get the error "No property, bindable property, or event found for 'GroupHeaderTemplate', or mismatching type between value and property"
With CollectionView
1- you don't need RecycleElement
2- does not include built-in separators; users can provide these (if desired) in their templates.
3- does not need HasUnevenRows
4- use SelectedItemCommand instead of ItemTapped
5- Grouping: https://docs.microsoft.com/it-it/xamarin/xamarin-forms/user-interface/collectionview/grouping
The property does not have SelectedItemCommand
Is there an easier way to force rendering since CollectionView must use bindable data?
I don't understand… what does it mean "the property does not have SelectedItemCommand"? SelectedItemCommand is a Command that is raised when you select an item on CollectionView and you can use it in MVVM.
Thanks. The problem was due to the CachingStrategy of the listview.