xamarin.Forms只滚动页面的一部分

use*_*474 5 layout scrollview xamarin

我有一个页面,我想在顶部始终查看标题,按钮始终在底部的视图中.中间的内容是可滚动的.

我认为这可以通过以下方式轻松实现:

StackLayout outer = new StackLayout();

StackLayout inner = new StackLayout();//with all of the content added

ScrollView scroll = new ScrollView();


outer.Children.Add(headerLabel);//non-scrolling

scroll.Content = inner;

outer.Children.Add(scroll);      //scrolling

outer.Children.Add(button);     //non-scrolling
Run Code Online (Sandbox Code Playgroud)

headerLabel和按钮保持在正确位置,但内容向上滚动到页面顶部,在headerLabel的顶部(但在底部按钮的下方/下方).

我很肯定它工作正常,但我不记得改变了什么.

有没有人知道为什么会发生这种情况?

use*_*474 6

所以这个修好了

outer.VerticalOptions = LayoutOptions.End;
Run Code Online (Sandbox Code Playgroud)

scroll.IsClippedToBounds=true;
Run Code Online (Sandbox Code Playgroud)