Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Xamarin.Forms - Label text disappears on android in Listview

dai15002dai15002 Member ✭✭✭
edited December 2019 in Xamarin.Forms

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 >




                                                    <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">
                                                                    <TapGestureRecognizer Tapped="ShowCompToastInfo" />





  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Try CollectionView

  • dai15002dai15002 Member ✭✭✭

    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"

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    edited December 2019

    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:

  • dai15002dai15002 Member ✭✭✭

    The property does not have SelectedItemCommand

    Is there an easier way to force rendering since CollectionView must use bindable data?

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    @dai15002 said:
    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.

  • dai15002dai15002 Member ✭✭✭

    Thanks. The problem was due to the CachingStrategy of the listview.

Sign In or Register to comment.