在Xamarin.Forms ScrollView中水平滚动

在Xamarin.Forms ScrollView中水平滚动

问题描述:

我正在使用Xamarin.Forms并创建了一个ScrollView,其中包含一个水平StackLayout.我希望能够水平滚动,所以我设置:

I am using Xamarin.Forms and have created a ScrollView, which contains a horizontal StackLayout. I want to be able to scroll horizontally, so I set:

Orientation  = ScrollOrientation.Horizontal;

但是我没有水平滚动. StackLayout的内容比屏幕宽,我看到内容在边缘被剪切.

But I don't get horizontal scroll. The content of the StackLayout is wider than the screen, and I see the content is being clipped at the edge.

如何使用Xamarin.Forms实现水平滚动?

How do I achieve horizontal scroll with Xamarin.Forms ?

这就是我的工作方式

      var scrollView = ScrollView
        {
            HorizontalOptions = LayoutOptions.Fill,
            Orientation = ScrollOrientation.Horizontal,

            Content = new StackLayout{
               Orientation = StackOrientation.Horizontal,
               Children = {}
            }
        };