Open MaksimNikonovOrioninc opened 3 years ago
Uno doesn't yet support ScrollViewer-related attached properties. There are a couple of different workarounds possible, depending exactly what you're trying to do. If you just want to disable scrolling completely, then you could modify the template of the ListView/GridView (using the Uno style as a starting point) and set HorizontalScrollMode="Disabled"
directly on the ScrollViewer inside the style. If you need to be able to toggle scrolling enabled, you might end up writing an attached behavior which looks for the ScrollViewer child of the list and sets the HorizontalScrollMode property dynamically.
@davidjohnoliver Setting HorizontalScrollMode="Disabled" on ScrollViewer not works, as workaround for this problem was iplemented next
#if NETFX_CORE
List.GetScrollViewer().VerticalScrollMode = ScrollMode.Disabled;
#elif __ANDROID__
var nativeList = (AndroidX.RecyclerView.Widget.RecyclerView)List.GetNativeListViewBase();
nativeList.AddOnScrollListener(ScrollListener);
#elif __IOS__
var nativeList = (UIKit.UICollectionView)List.GetNativeListViewBase();
nativeList.ScrollEnabled = false;
#endif
For android also was implemented custom scroll listener
public class DisableScrollOnScrollListener : RecyclerView.OnScrollListener
{
public override void OnScrollStateChanged(RecyclerView recyclerView, int newState)
{
base.OnScrollStateChanged(recyclerView, newState);
recyclerView.StopScroll();
}
}
Hope that would help to someone
Current behavior
Unable to disable Scroll behavior for ListView or GridView
Expected behavior
For ListView and GridView possible to change scroll behaviurs
How to reproduce it (as minimally and precisely as possible)
Workaround
Environment
Nuget Package:
Nuget Package Version(s):
Affected platform(s):
IDE:
Relevant plugins:
Anything else we need to know?