为什么 ScrollView 在 FlyoutHeaderTemplet 中不起作用?

问题描述

<Shell.FlyoutHeaderTemplate>
    <DataTemplate>
        <ScrollView>
             <StackLayout>
    .....................................
             <StackLayout/>
        <ScrollView/>
    </DataTemplate>
</Shell.FlyoutHeaderTemplate>

StackLayout里面有很多内容被截断了。

解决方法

我根据您的代码对示例Xaminals进行了测试,并使用了以下代码,运行正常。

可以参考如下代码:

    <Shell.FlyoutHeaderTemplate>
    <DataTemplate>
        <ScrollView>
            <StackLayout Orientation="Vertical" HeightRequest="600" BackgroundColor="DarkGreen">
                <Image Aspect="AspectFill" 
                   Source="watermelon.png" 
                       HeightRequest="550"
                       WidthRequest="550"
                   Opacity="0.6" />
                <Label Text="test header" 
                   TextColor="White" 
                   FontAttributes="Bold" 
                   HorizontalTextAlignment="Center"
                   VerticalTextAlignment="Center" />

            </StackLayout>
            </ScrollView>
    </DataTemplate>
</Shell.FlyoutHeaderTemplate>

结果是: enter image description here