[Bug] iOS: CollectionView items don't change their size when item content size is changed
Description
CollectionView items don't change their size when item content size is changed
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp.MainPage" BackgroundColor="White">
<StackLayout>
<Button Text="Button" Clicked="Button_Clicked"/>
<CollectionView ItemsSource="{Binding Items}" >
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid>
<Label Text="{Binding Name}"/>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</ContentPage>
public partial class MainPage : ContentPage {
public MainPage() {
InitializeComponent();
BindingContext = this;
}
ObservableCollection<SomeItem> _items;
public ObservableCollection<SomeItem> Items {
get {
if (_items == null) {
_items = new ObservableCollection<SomeItem>(Enumerable.Range(0, 5).Select(c => {
return new SomeItem() { Name = string.Format("Item {0}", c) };
}));
}
return _items;
}
}
void Button_Clicked(System.Object sender, System.EventArgs e) {
foreach (SomeItem item in Items) {
item.Name = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
}
}
public class SomeItem : INotifyPropertyChanged {
string name;
public string Name {
get => name;
set {
name = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Name)));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
Expected Behavior
All items change their height
https://user-images.githubusercontent.com/41049348/144585428-ded1d957-bef0-4caf-bf99-9029ccc7624a.mov
Actual Behavior
All items don't change their height
https://user-images.githubusercontent.com/41049348/144585558-f9c8ed20-166e-46e3-ab46-aa6c01d3d720.mov
Steps to Reproduce
- Create a MAUI app
- Put Button and CollectionView into StackLayout on the MainPage.xaml
- Set ItemTemplate for CollectionView, put into ItemTemplate Grid with Label
- In the Button.Clicked event handler change Label.Text
- Deploy to iOS simulator and click the Button
Version with bug
Preview 10 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 15
Did you find any workaround?
No response
Relevant log output
No response
Verified Repro with iPhone 13 pro max IOs 15.2. Repro project 3643.zip
Hello, we are developing DevExpress .NET MAUI controls and experienced the same issue in our CollectionView. This issue has a High priority for us and we have/do not have a workaround. Thank you for your help.
Still an issue on 6.0.300-rc.4.5742
This is a major issue for us, we need to deploy our Ecommerce app to store, but handling items in CollectionView is hard, we need to set MaxHeightReq not to take huge vertical space. If CollectionView is empty, we also get huge blank vertical space.
I am facing this issue as well. ListView updates properly but CollectionView does not.