maui: ScrollView with BindableLayout.ItemsSource is not recalculate new size on iOS
Description
I have this code, and after I changed Slots collection, ScrollView is not recalulate it’s size.
<ScrollView x:Name="scrollView" VerticalScrollBarVisibility="Default">
<Grid>
<StackLayout Margin="16,0">
<StackLayout x:Name="DaysCollection" BindableLayout.ItemsSource="{Binding Days}" Spacing="18">
<BindableLayout.ItemTemplate>
<DataTemplate x:DataType="general:AvailabilityDayModel">
<StackLayout Spacing="20">
<StackLayout x:Name="AvailabilitySlot" BindableLayout.ItemsSource="{Binding Slots}" Spacing="4">
<BindableLayout.ItemTemplate>
<DataTemplate x:DataType="general:AvailabilitySlotModel">
<HorizontalStackLayout>
<Label Text="-" Style="{StaticResource ParagraphRegular}" Margin="8" VerticalOptions="Center" />
<Button ImageSource="trash.png" Clicked="RemoveAvailability_Clicked" Margin="-8"
CommandParameter="{Binding .}" BackgroundColor="Transparent" VerticalOptions="Center"
Style="{StaticResource SecondaryDefaultSmall}" />
<Button ImageSource="plus_big.png" Clicked="AddAvailability_Clicked" Margin="-8"
CommandParameter="{Binding ParentDay}" BackgroundColor="Transparent" VerticalOptions="Center"
Style="{StaticResource SecondaryDefaultSmall}" />
</HorizontalStackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
<Button IsVisible="{OnIdiom false, Phone=true}" Text="Save" Command="{Binding SaveChangesCommand}" Margin="16,32,16,0" Style="{StaticResource MainDefaultBig}" />
</StackLayout>
</Grid>
</ScrollView>
Steps to Reproduce
- Create ScrollView
- Inside ScrollView add Grid, then StackView
- Add one more StackView with BindableLayout.ItemsSource
- add one more butto wich will add new item into BindableLayout.ItemsSource and will rise event to add one more item
- on iOS after adding items ScrollView will not recalulate size and you will not see scroll
- on Android all is ok
Link to public reproduction project repository
no
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 16
Did you find any workaround?
If I will call InvalidateMeasure(); after adding items in Page all is fine, so it looks like ScrollView not notified about chagin size of childrens
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 4
- Comments: 18 (6 by maintainers)
Issue also occurs on Windows. I think this needs some urgent attention. Looks like there are related issues too (#13246 and #11987).
Have the exact same issue!
https://github.com/Sokol2001/BindableLayoutIssue
BindableLayoutIssue.zip
I can’t reproduce my problem specifically, maybe because I now have a dotnet 7.200 preview But in my example there is a new problem, that after adding an internal element, the application no longer responds to buttons.
Confirmed, fixed by #16385.
It’s possible this is fixed by #16385.
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Can repro on iOS platform with sample project. BindableLayoutIssue.zip
exactly the same issue
Similarly, clicks on elements stopped working on ios.