单击任何子元素时,Xamarin Forms ScrollView 会自动滚动到开头
Xamarin Forms ScrollView scrolls automatically to the beginning when any child element is clicked
我在 Xamarin Forms 中创建了一个水平/垂直滚动视图,其中包含多种类型的子项,例如:
- 标签
- 自定义复选框
- ImageViews
- 选择器
- 滑块
这是我的代码:
ScrollView scrollTracks = new ScrollView
{
BackgroundColor = Color.Black,
VerticalOptions = LayoutOptions.StartAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Content = layoutTracks,
Orientation = ScrollOrientation.Both
};
当我单击某些子元素(如 CustomCheckboxes、Labels 或 ImageViews)时,程序会自动将视图滚动到开头。
我在 UWP 平台上测试过。
如何让程序停止这样做?
将此标记添加到 ScrollView 解决了我的问题:
IsTabStop = false
这里是代码:
ScrollView scrollTracks = new ScrollView
{
BackgroundColor = Color.Black,
VerticalOptions = LayoutOptions.StartAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Content = layoutTracks,
Orientation = ScrollOrientation.Both,
IsTabStop = false
};
我在 Xamarin Forms 中创建了一个水平/垂直滚动视图,其中包含多种类型的子项,例如:
- 标签
- 自定义复选框
- ImageViews
- 选择器
- 滑块
这是我的代码:
ScrollView scrollTracks = new ScrollView
{
BackgroundColor = Color.Black,
VerticalOptions = LayoutOptions.StartAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Content = layoutTracks,
Orientation = ScrollOrientation.Both
};
当我单击某些子元素(如 CustomCheckboxes、Labels 或 ImageViews)时,程序会自动将视图滚动到开头。
我在 UWP 平台上测试过。
如何让程序停止这样做?
将此标记添加到 ScrollView 解决了我的问题:
IsTabStop = false
这里是代码:
ScrollView scrollTracks = new ScrollView
{
BackgroundColor = Color.Black,
VerticalOptions = LayoutOptions.StartAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Content = layoutTracks,
Orientation = ScrollOrientation.Both,
IsTabStop = false
};