【问题标题】:Xamarin Forms ScrollView scrolls automatically to the beginning when any child element is clicked单击任何子元素时,Xamarin Forms ScrollView 会自动滚动到开头
【发布时间】:2021-05-04 04:17:09
【问题描述】:

我在 Xamarin Forms 中创建了一个水平/垂直滚动视图,其中包含多种类型的子项,例如:

  • 标签
  • 自定义复选框
  • 图像视图
  • 选择器
  • 滑块

这是我的代码:

ScrollView scrollTracks = new ScrollView
{
     BackgroundColor = Color.Black,
     VerticalOptions = LayoutOptions.StartAndExpand,
     HorizontalOptions = LayoutOptions.FillAndExpand,
     Content = layoutTracks,
     Orientation = ScrollOrientation.Both
};

当我单击一些子元素(如 CustomCheckboxes、Labels 或 ImageViews)时,程序会自动将视图滚动到开头。

我在 UWP 平台上对此进行了测试。

我怎样才能让程序停止这样做?

【问题讨论】:

标签: xamarin xamarin.forms click scrollview touch


【解决方案1】:

将此标签添加到 ScrollView 解决了我的问题:

IsTabStop = false

代码如下:

ScrollView scrollTracks = new ScrollView
{
     BackgroundColor = Color.Black,
     VerticalOptions = LayoutOptions.StartAndExpand,
     HorizontalOptions = LayoutOptions.FillAndExpand,
     Content = layoutTracks,
     Orientation = ScrollOrientation.Both,
     IsTabStop = false
};

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多