Forum Xamarin.Forms

How to implement readmore in listview items?

RichyRichy Member ✭✭

How to implement need readmore and read less inside listview item as it expand and collapse content respectively?

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Try to separately create designs for each situation. And then define an isExpand property in your view model.
    Use datatemplate selector to display expand cell when this property is true and so does the collapse cell when it is false:
    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/templates/data-templates/selector
    This "See more" button's click event could be used to change the property and reload the cell.

  • RichyRichy Member ✭✭
    > @LandLu said:
    Is there any way in xamarin.forms to find if the label is truncated or not?
  • LandLuLandLu Member, Xamarin Team Xamurai

    There is not an api on Forms to detect this.
    We need to use dependency service to calculate the size of the text on each platform.
    And then compare it to the actual label size to get the result.
    Maybe, GetSizeUsingAttributes for iOS and MeasureText in Android could be considered.

Sign In or Register to comment.