How to Add two ListViews in ScrollView in Xamarin Forms ?

Andrew1993Andrew1993 USMember ✭✭
edited January 2017 in Xamarin.Forms

I've tried two ListViews in Scroll View but the problem I've faced is that the data of second ListView is not fully displayed on the Page .
Here's is my code for that .
I've also tried this in StaclLayout but not getting the actual result.

Best Answers

Answers

  • Andrew1993Andrew1993 USMember ✭✭
    edited January 2017


    Then is this possible to achieve that kinda result in Xamarin Forms ?
    @AlessandroCaliaro @JohnHardman
    Both should be in One Scroll View but different ListView Header and Different ListView Border Radius ?
    I know how to write custom renderer for that purpose but not sure Is this possible or Not ?
    When I write a rounded custom renderer for ListView then ListView changes but it also changes the Header but I don't want this . What I want is a Rounded ListView and a Rounded ListView Header but both should be seperate .
    Any help or hope for this ?

    LV.png 12.8K
  • JohnHardmanJohnHardman GBUniversity mod

    @Andrew1993 - Without the rounded corners on the list body, definitely. With the rounded corners, it take a bit more effort.

  • Andrew1993Andrew1993 USMember ✭✭

    @JohnHardman . Don't worry about the ListView Custom Rendering
    I've created the Header by using custom renderers and the following code
    _commentsList.HeaderTemplate = new DataTemplate(() =>
    {
    ContentView topView = DynamicPostController.Instance.GetPostMainViewForModel(pModel) as ContentView;
    }
    but not sure how to handle the ListView ?

  • JohnHardmanJohnHardman GBUniversity mod

    @Andrew1993 - Which aspect of the ListView are you not sure about?

  • Andrew1993Andrew1993 USMember ✭✭

    I've created the ListView rounded Header but when I create the Custom Renderer for rounded ListView it will round the ListView from the top including the Header as well and if I create the StackLayout in the ViewCell then it will round all the ViewCell but what I want is a rounded ListView with rectangular ViewCells . Hope you understand the question ? @JohnHardman

  • JohnHardmanJohnHardman GBUniversity mod

    @Andrew1993 - If you really need the body of the ListView to have rounded corners, I would do what you are not normally advised to do. That is, to have what is currently the Header of the ListView as a completely separate control, so that the ListView itself does not have a header. That way, your ListView custom renderer will apply the rounding to what appears to the user to be the body of the ListView, but is actually the whole ListView (the header being a separate control).

  • Andrew1993Andrew1993 USMember ✭✭

    @JohnHardman Yeah you're right but may be this thing will disturb the Scrolling of ListView...
    I've some thing in my mind that Is this possible to create a ListView in side the ListView means nested ListView ?
    What you say ?

  • JohnHardmanJohnHardman GBUniversity mod

    @Andrew1993 - Nesting a ListView inside a ListView will have the same UX implications as a ListView inside a ScrollView. Best avoided.

  • kenneth.leekenneth.lee USMember ✭✭✭

    Im reading through the comments and i don't quite understand fully where the problem is... Is the problem with the UI not knowing when scrolling which object is trying to be scrolled?

    If thats the case would it be ok to say make 2 listview which doesn't scroll and display all objects by increasing its Height and then proceed to put them into a scrollview?

    @JohnHardman please clarify thanks.

  • JohnHardmanJohnHardman GBUniversity mod

    @kenneth.lee

    "Note: ScrollViews should not be nested. In addition, ScrollViews should not be nested with other controls that provide scrolling, like ListView and WebView."

    Ref. https://developer.xamarin.com/guides/xamarin-forms/user-interface/layouts/scroll-view/

    Re. putting non-scrolling ListViews inside a ScrollView - hmmm.... I'd call that a gray area. I think the Xamarin view would be that it's not supported. However, from a UX point of view, if it works then I think it should be ok, subject to caveats about pull-to-refresh etc.

  • kenneth.leekenneth.lee USMember ✭✭✭

    @JohnHardman Oh I completely missed that when i went through that document... Yeah i did try that and it seems to be working ok on iOS and Android... i cant confirm for windows tho. Thanks for clearing that up

Sign In or Register to comment.