Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Listview scroll doesn't work inside a swipeview

nonubittanonubitta Member ✭✭

I have a listview inside of a stacklayout. After loading the listview, I need to scroll it down to the 20th item. It works fine.
But due to another requirement when I nest the stacklayout inside a swipeview, following code stops working.

lstView.ScrollTo(SelectedItem, ScrollToPosition.Start, false);

This works fine:

<StackLayout>
    <ListView>
    </ListView>
</StackLayout>

This does not:

 <SwipeView>
    <StackLayout>
        <ListView>
        </ListView>
    </StackLayout>
</SwipeView>

Best Answers

  • nonubittanonubitta Member ✭✭
    Accepted Answer

    You are right this part was working correctly.
    The problem was there was another stacklayout after swipelayout which was causing issue.
    Once I moved it inside swipeview, everything worked fine.

    Not working code:

     <SwipeView>
        <StackLayout>
            <ListView>
            </ListView>
        </StackLayout>
    </SwipeView>
    <StackLayout x:Name="OuterSL">
     </StackLayout>
    

    Fix:

    <SwipeView>
        <StackLayout>
                <StackLayout>
                    <ListView>
                    </ListView>
                </StackLayout>
            <StackLayout x:Name="OuterSL">
             </StackLayout>
        </StackLayout>
    </SwipeView>
    

Answers

  • nonubittanonubitta Member ✭✭
    Accepted Answer

    You are right this part was working correctly.
    The problem was there was another stacklayout after swipelayout which was causing issue.
    Once I moved it inside swipeview, everything worked fine.

    Not working code:

     <SwipeView>
        <StackLayout>
            <ListView>
            </ListView>
        </StackLayout>
    </SwipeView>
    <StackLayout x:Name="OuterSL">
     </StackLayout>
    

    Fix:

    <SwipeView>
        <StackLayout>
                <StackLayout>
                    <ListView>
                    </ListView>
                </StackLayout>
            <StackLayout x:Name="OuterSL">
             </StackLayout>
        </StackLayout>
    </SwipeView>
    
Sign In or Register to comment.