1

I'm having a vertical list view which has in its item template another list view in horizontal position, now everything works fine, but I want to be able to scroll all of these sub list views if one of them scrolled.

Here is an illustration: Illustration

Now I want all the sub list views in all rows to scroll together. How can I do this?!

Maybe I can make an extending class for the list view with bindable property for scrolling ?! Something like this:

public class ScrollableListView : ListView {
    public static readonly BindableProperty ScrollProperty = BindableProperty.Create("ScrollPosition", typeof(double), typeof(ScrollableListView));
    public double ScrollPosition
    {
        get { return (double)GetValue(ScrollProperty ); }
        set
        {
            SetValue(ScrollProperty, value);
            ScrollToAsync(0, value);
        }
    }
}

And then in xaml bind all ScrollPosition property to a variable that changes whenever a list is scrolled, like this:

<DataTemplate>
    <RelativeLayout HeightRequest="{Binding Width}" Margin="{Binding Margin}">
        <Grid Rotation="90" AnchorX="0" AnchorY="0"
              RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
              RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height}"
              RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}">

            <Local:ScrollableListView ScrollPosition="{Binding SPos}" Scrolled="Generic_Scroll_Event"/>
        </Grid>
    </RelativeLayout>
</DataTemplate>

And in the Generic_Scroll_Event The SPos variable changes to the event sender's position.

This is just something that popped in my head ... Any help is appreciated anyway ^^.

5
  • Can you provide one sample that you have tried here? I will try to reproduce your problem and try to give one solution. Commented Oct 19, 2020 at 8:27
  • Well, I tried, but ScrollTo functions doesn't take position -_- instead, an item to scroll to... Commented Oct 27, 2020 at 1:33
  • Please provide one simple sample at github, I will download your sample to test, and try to give one solution. Commented Oct 27, 2020 at 5:47
  • There is no sample... I have nothing to test... I'm not looking for a fix, I'm looking for an idea or some workaround to achiever the job, which is making multiple listviews scroll together. Commented Oct 29, 2020 at 7:23
  • If you don't provide simple sample, I can not reproduce your problem at my side. Commented Nov 3, 2020 at 5:50

1 Answer 1

0

The above answer should work, but as there is no direct way of making a listview scroll to a position I had to make a workaround.

I used scrollviews instead and used it's template to work as a listview, then binded all of the scrollviews to the first one, in two way mode.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.