Forum Xamarin.Forms

How can i fill my ListView from bottom to top?

l_Nort_ll_Nort_l Member ✭✭

I need the chat messages to appear in the ListView from bottom to top, and not vice versa.
I am creating an Instagram chat using the API in Android.
Screenshots:

Now:

As i need:

Best Answer

  • l_Nort_ll_Nort_l Member ✭✭
    Accepted Answer

    I found a solution!
    To display data in a ListView from bottom to top you need:

    • rotate ListView 180 °:
      <ListView Rotation="180" />

    • rotate the cells in which data is displayed, in my case it is StackLayout and Frame:
      <StackLayout Rotation="180" />
      <Frame Rotation="180" />

    • flip the data that is displayed:
      data.Reverse();

    • since I am creating a chat, I need to set the direction of StackLayout:
      <StackLayout FlowDirection="RightToLeft" />
      ~~~~
      Since I'm not a professional, the code is subject to improvement and redoing.
      P.S. Everything works for me and I'm glad 🙃
      Result:

Answers

  • l_Nort_ll_Nort_l Member ✭✭
    Accepted Answer

    I found a solution!
    To display data in a ListView from bottom to top you need:

    • rotate ListView 180 °:
      <ListView Rotation="180" />

    • rotate the cells in which data is displayed, in my case it is StackLayout and Frame:
      <StackLayout Rotation="180" />
      <Frame Rotation="180" />

    • flip the data that is displayed:
      data.Reverse();

    • since I am creating a chat, I need to set the direction of StackLayout:
      <StackLayout FlowDirection="RightToLeft" />
      ~~~~
      Since I'm not a professional, the code is subject to improvement and redoing.
      P.S. Everything works for me and I'm glad 🙃
      Result:

Sign In or Register to comment.