Improvement on Nesting CardView in ScrollView
See original GitHub issueImprovement on nesting CardView in ScrollView. Your workaround is completely functional, save the fact that it doesn’t enable high velocity scrolls (when a user scrolls fast and lifts it only scrolls a little bit). I have a suggestion to avoid the interface and possibly fix the scrolls not feeling smooth with the current workaround.
Put a boolean bindable prop in the card control named something like AutoFindAndScrollParentScroll. What could be better about finding the parent is that you could add a custom Effect to whatever ScrollView is the parent and it could properly pass the pan effect to the ScrollView using the native Effect.
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/effects/introduction
then if its true do something like this on vertical panning:
ScrollView scrollView = null;
var parent = this.Parent;
while (parent != null)
{
if (parent.GetType() == typeof(ScrollView) || parent.GetType().IsSubclassOf(typeof(ScrollView)))
{
scrollView = parent as ScrollView;
break;
}
parent = parent.Parent;
}
scrollView.ScrollToAsync(0, yValue);
// OR even better add the effect to the scrollview to pass pan args natively
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (7 by maintainers)
Top GitHub Comments
Oh damn sorry didn’t see that lol. It works now thanks!
I tried it and it works the same way as adding the interface. It’s just all done inside the CardView. I made a PR. More work is needed to make the scrolling more fluid. This has to be done natively. If I have time ill look into it and adding an effect to the ParentScrollView I added in the PR.