xamarin-zebblezebble

Zebble: Percentage value for ScrollView Height doesn't work


I'm trying to use a ScrollView in my UWP project. The problem is that when I assign a fixed value to my ScrollView Height, it works perfectly fine. However, if I assign a percentage value to its Height, it simply doesn't work and nothing is shown on that page, only a white blank screen.

Here's an example of a fixed value that works:

  <ScrollView Id="MainScroll" Style.Height="700">
    <Modules.TimeLineList></Modules.TimeLineList>
  </ScrollView>

But, the following doesn't work and shows a white blank screen:

  <ScrollView Id="MainScroll" Style.Height="100%">
    <Modules.TimeLineList></Modules.TimeLineList>
  </ScrollView>

In addition, the Modules.TimeLineList in the above examples is a ListView defined in another file and it contains some normal ImageView and TextView elements. Any help is much appreciated.


Solution

  • I suppose you have placed the ScrollView inside a Stack (Pages are Stacks too). When you place a ScrollView inside a Stack you can't set the percentage based height for it.

    Vertical stacks' height is calculated based on the overall height of their content (In this case ScrollView). At the same time, ScrollView tries to find the height of its parent (Stack) to calculate it's height based on its height. And it will prevent both from having proper height.

    If you read your output messages, you will probably find some errors or warnings about it.

    You can fix it by using a fixed height either for ScrollView or Stack.