Skip to content
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

CollectionView does not update when changing ItemsLayout #7747

Open
mattleibow opened this issue Jun 4, 2022 · 3 comments
Open

CollectionView does not update when changing ItemsLayout #7747

mattleibow opened this issue Jun 4, 2022 · 3 comments
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/windows 🪟 s/triaged Issue has been reviewed t/bug Something isn't working
Milestone

Comments

@mattleibow
Copy link
Member

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:

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

@mattleibow mattleibow added t/bug Something isn't working s/needs-verification Indicates that this issue needs initial verification before further triage will happen area-controls-collectionview CollectionView, CarouselView, IndicatorView s/verified Verified / Reproducible Issue ready for Engineering Triage and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Jun 4, 2022
@mattleibow mattleibow added this to the 6.0-sr2 milestone Jun 4, 2022
@StepKie
Copy link

StepKie commented Jun 16, 2022

The same is true for ListView, btw.
When calling OnPropertyChanged(nameof(OverallRecords) (no matter if it is an ObservableCollection, ObservableRangeCollection or a basic List), the content of the collection view only updates when the area is manually scrolled.

After calling OnPropertyChanged(nameof(OverallRecords), in the following case

  • FirstRecord updates correctly, with ViewModel code:
    public string FirstRecord => OverallRecords.FirstOrDefault()?.Record.Team.Name ?? "NONE";

  • The CollectionView only updates after click/scroll ...

     <Label Text="{Binding FirstRecord}" />
     <ListView ItemsSource="{Binding OverallRecords}">
       <ListView.ItemTemplate>
         <DataTemplate>
           <ViewCell>
             <Label Text="{Binding Record.Team.Name}" />
           </ViewCell>
         </DataTemplate>
       </ListView.ItemTemplate>
     </ListView>

This cost me a good five hours to debug, and then I find this existing issue.
Incredible for a GA version of MAUI, really ... :(

@ghost
Copy link

ghost commented Aug 30, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@ToolmakerSteve
Copy link

ToolmakerSteve commented Oct 2, 2022

FWIW: I haven't looked at what Collection/ListView issues have been closed in the past two months, but initially there were MANY issues that came down to "Collection/ListView does not correctly update its layout when it should".

This sounds like yet another one.

Interestingly, programmatically forcing a layout does NOT (or at least didn't at the time) fix any of those. I infer that certain information is cached when the view is first built, and not correctly re-calculated in later layout cycles.

@samhouts samhouts removed the s/verified Verified / Reproducible Issue ready for Engineering Triage label Apr 5, 2023
@jsuarezruiz jsuarezruiz self-assigned this Apr 11, 2023
@jsuarezruiz jsuarezruiz moved this from Todo to In Progress in MAUI SDK Ongoing Apr 12, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Apr 28, 2023
@samhouts samhouts modified the milestones: Backlog, .NET 8 May 24, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.4.8333 Look for this fix in 8.0.0-preview.4.8333! label Jun 8, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 8, 2023
@PureWeen PureWeen reopened this Oct 26, 2023
@PureWeen PureWeen removed this from the .NET 8 + Servicing milestone Oct 26, 2023
@PureWeen PureWeen added this to the Backlog milestone Oct 26, 2023
@samhouts samhouts removed the fixed-in-8.0.0-preview.4.8333 Look for this fix in 8.0.0-preview.4.8333! label Oct 31, 2023
@Zhanglirong-Winnie Zhanglirong-Winnie added the s/triaged Issue has been reviewed label Dec 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/windows 🪟 s/triaged Issue has been reviewed t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants