如何设置 ScrollView 内容的大小?

how do I SET the size of the ScrollView content?

现在 ScrollView ContentSize 属性 是只读的,我该如何设置 ScrollView 内容的大小? 在 UIScrollView 中可设置的 属性 (但不是 xamarin 形式)

我有这个:

  <ScrollView Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" HorizontalOptions="FillAndExpand"
              x:Name="attachmentScroller"
              >
    <StackLayout x:Name="AttachmentsView" Orientation="Horizontal" VerticalOptions="Fill"/>
  </ScrollView>

我尝试过将 AttachmentsView.MinimumWidthRequest 设置为所需的 contentWidth; 但这似乎并没有扩大 parent 的滚动视图内容宽度 到所需的值。

您可以通过设置内容的 属性 而不是 ScrollView 来设置内容大小。

这是xaml

<ScrollView>
    <StackLayout HeightRequest="100" />
</ScrollView>

要停止滚动视图将所含内容的大小限制为自己的大小,请确保设置

ScrollView Orientation="Horizontal" 或 "Both" 或 "Vertical"。

即对于你的例子 -

 <ScrollView Orientation="Horizontal" Grid.Row="1" 
     Grid.Column="0" Grid.ColumnSpan="3" 
     HorizontalOptions="FillAndExpand"
     x:Name="attachmentScroller">

 <StackLayout WidthRequest="1000" x:Name="AttachmentsView"
     Orientation="Horizontal" VerticalOptions="Fill"/>

 </ScrollView>