You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently trying to achieve a design similar to a Bottom Sheet that contains a dynamic list of items towards the bottom of the screen. The idea is to have the bottom view grow or shrink based on the number of items. When the "Bottom Sheet" is at max height then the list of items should be scrollable.
As long as there are just a couple of items, I can achieve the desired layout by just putting the ListView inside a Grid with a row definition of "Auto".
However, when there are a large amounts of items, so the wrapping view grows to 100%, then I found out that the scrolling does not work. I tried putting it inside a VerticalStackLayout to test. What I could find online was that this was expected behavior, that the Row definition has to be '*' . However, using ' *' as the row definition results in the ListView expanding and taking up the entire screen, even when it only has 1 item.
It is possible to restrict the ListView's height by setting the MaximumHeightRequest to a value, but what value...
I had an idea then to ask the ListView control how large it needed to be, but I could only get results based on what it desired to be, which was max height. I tried to specify the VerticalOptions to be "End" and "EndAndExpand", but that made no difference.
I have a faint memory when I was doing native iOS that I could access the scrolling area or do something else to actually get the calculated desired scroll area.
So, I would really like it if it was possible to ask a ListView or CollectionView for their required scrolling area size, or just ask it to hug its content instead of trying to take all the available space.
It would also be great to be able to set scrolling padding(?) so it would be possible to have a ListView or CollectionView inside the SafeAreaInsets and use padding/scroll insets to make sure that the last element can clear the safe area.
Please help 🙏
Update
Seems I can get the correct desired content/height returned from the ListView by calling Measureif I set HasUnevenRows to false and set RowHeight to a fixed value. I don't like the idea of a fixed row height as it won't work with font scaling or if the <DataTemplate> changes. How does the Grid with a RowDefinition of auto get the correct desired content/height when I have HasUnevenRows set to true and no fixed RowHeight?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am currently trying to achieve a design similar to a Bottom Sheet that contains a dynamic list of items towards the bottom of the screen. The idea is to have the bottom view grow or shrink based on the number of items. When the "Bottom Sheet" is at max height then the list of items should be scrollable.
As long as there are just a couple of items, I can achieve the desired layout by just putting the ListView inside a Grid with a row definition of "Auto".
However, when there are a large amounts of items, so the wrapping view grows to 100%, then I found out that the scrolling does not work. I tried putting it inside a VerticalStackLayout to test. What I could find online was that this was expected behavior, that the Row definition has to be '*' . However, using ' *' as the row definition results in the ListView expanding and taking up the entire screen, even when it only has 1 item.
It is possible to restrict the ListView's height by setting the MaximumHeightRequest to a value, but what value...
I had an idea then to ask the ListView control how large it needed to be, but I could only get results based on what it desired to be, which was max height. I tried to specify the VerticalOptions to be "End" and "EndAndExpand", but that made no difference.
I have a faint memory when I was doing native iOS that I could access the scrolling area or do something else to actually get the calculated desired scroll area.
So, I would really like it if it was possible to ask a ListView or CollectionView for their required scrolling area size, or just ask it to hug its content instead of trying to take all the available space.
It would also be great to be able to set scrolling padding(?) so it would be possible to have a ListView or CollectionView inside the SafeAreaInsets and use padding/scroll insets to make sure that the last element can clear the safe area.
Please help 🙏
Update
Seems I can get the correct desired content/height returned from the
ListView
by callingMeasure
if I setHasUnevenRows
tofalse
and setRowHeight
to a fixed value. I don't like the idea of a fixed row height as it won't work with font scaling or if the<DataTemplate>
changes. How does theGrid
with aRowDefinition
ofauto
get the correct desired content/height when I haveHasUnevenRows
set totrue
and no fixedRowHeight
?Beta Was this translation helpful? Give feedback.
All reactions