-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: adding child views at runtime to FlexLayout or StackLayout? #18
Comments
For what reason do you prefer Stack- or FlexLayout? Alternatively consider: |
@reigam it's mostly just where I ended up before this new "dynamically adding views" requirement came to light and I was hoping there was a way to make things work without what would more or less be a full overhaul of the page in question (which is a lot more complex than the toy example I provided). Other than this issue, the behaviour of FlexLayout would have been perfect and easy for what I was trying to do. After now spending several evenings unsuccessfully trying to make this work, I already suspected I would need to cut my losses and go with a different approach. But before spending significant time on re-work, I wanted to get some idea of other's experience to make sure that this re-work would be on the right track. I was thinking about a Grid, but maybe CollectionView would be easier for this. I'll need to do some experimentation. Thanks. |
I might have a suggestion for a work-around for your problem. I'll get back to you. Edit 1: Your solution works fine on UWP and WPF (iOS not tested). On android you can use the following workaround (not really a solution, more a proof of concept):
Basically, unloading and reloading the view fixes the scrolling problem. Edit2: Edit3 = some improvements to the code above Edit 4: no scrolling problems with your original code on iOS either, seems to be an 'android only' problem. |
Hey @reigam, I appreciate the help. Yeah, I've been mostly testing on Android and iOS (just Android for this issue so far) as these are the only relevant platforms for the project in question. I noticed that things seem to reappear when the views are updated again, subsequent to the addition of the child views on the previous update. I did end up using a CollectionView rather than ScrollView + FlexView. It doesn't work out exactly as I had envisioned in terms of layout appearance/behaviour, but will work fine. After having sorted out overall scrolling for the page, I then realised I had a child ListView inside the parent CollectionView. But that's a different story. |
Hello! I'm back with another possibly silly question.
I have a situation where I need to add child views to - preferably - a FlexLayout or StackLayout, at runtime, after the first
init
call, based on user input. The child views can be of different types, depending on the user input and values that are periodically retrieved/updated from a remote source and saved into an SQLite database in the app.I had hoped that I could just wrap a FlexLayout in a ScrollView and when I insert the new child views, things would expand to accomodate, even if the overall height ends up taller than the device screen. It seems that FlexLayout does not do this. What I'm seeing is that the ScrollView does seem to account for the height of the newly inserted elements but neither a FlexLayout or StackLayout do. So the result is that after the new child views are inserted, any child views that end up below the overall height of the screen are not shown, but the ScrollView none the less acts like they are there and one can scroll "below the fold" to see only empty space.
Before I start tearing out code wholesale to try and find a completely different way to do this, can anyone point me in the direction of a good way to dynamically insert heterogeneous child views like this, with Fabulous?
A simplified and contrived example of what I'm trying to do (based off the Fabulous example app):
The text was updated successfully, but these errors were encountered: