Issue
I am trying to lock the height of a header - or basically any kind of content on the top of a page. However, once scrollable content is added below the height changes. A simple example:
<ContentPage.Content>
<StackLayout Padding="0" Margin="0" Spacing="0">
<Frame Margin="0" HeightRequest="150" BackgroundColor="red" CornerRadius="0" HasShadow="False" Padding="0"></Frame>
</StackLayout>
</ContentPage.Content>
This works fine. However, adding a lot of simple label lines in a scrollview somehow changes the height of the frame.
<ContentPage.Content>
<StackLayout Padding="0" Margin="0" Spacing="0">
<Frame Margin="0" HeightRequest="150" BackgroundColor="red" CornerRadius="0" HasShadow="False" Padding="0"></Frame>
<ScrollView>
<StackLayout>
<Label Text="aaa" /> <!-- Repeated 54 times however removed here for simplicity-->
</StackLayout>
</ScrollView>
</StackLayout>
</ContentPage.Content>
The results end up like this:
Why does it happen and can I do anything to avoid it? And why is the height reduced to exactly that height? Thanks!
Solution
It doesn't seem like you're limiting the height of the ScrollView. So considering you're merely doing a HeightRequest, it may change as needed to fit everything. It's usually safer to use Grids. In this example, something like this could help you:
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="150" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Frame Grid.Row="0" Margin="0" BackgroundColor="red" CornerRadius="0" HasShadow="False" Padding="0"></Frame>
<ScrollView Grid.Row="1">
<StackLayout>
<Label Text="aaa" /> <!-- Repeated 54 times however removed here for simplicity-->
</StackLayout>
</ScrollView>
</Grid>
</ContentPage.Content>
Answered By - Kevin K Varughese
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.