CollectionView does not update when changing ItemsLayout
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
### Description
I have a CollectionView with several items and I want to make a 2 column layout on wide screens and a 1 column layout on tall screens.
I tried setting a GridItemsLayout and changing the Span, but that did not work and then I tried changing the entire ItemsLayout, but still no updates in the app.
Restarting the app works, so this is just the result of changing at runtime.
### Steps to Reproduce
Add a CollectionView with items, and then say write this code to toggle the layout on page size changes:
```cs
private void OnSizeChanged(object? sender, EventArgs e) =>
collectionView.ItemsLayout = Width > 600
? new GridItemsLayout(2, ItemsLayoutOrientation.Vertical)
: new LinearItemsLayout(ItemsLayoutOrientation.Vertical);
```
> NOTE: this should all be doable with AdaptiveTriggers, but that is not working currently #7242
### Version with bug
6.0 (current)
### Last version that worked well
Unknown/Other
### Affected platforms
Windows
### Affected platform versions
All
### Did you find any workaround?
_No response_
### Relevant log output
_No response_
Contributor guide
Research direction
Start with the supplied OnSizeChanged reproduction and trace how CollectionView handles runtime assignments to ItemsLayout, including switching between GridItemsLayout and LinearItemsLayout. Done means the visible CollectionView updates its layout without restarting the app; verify the behavior on Windows with the reported size-change scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100