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 change the user interface when modifying an ObservableCollection element #22277

Closed
DevRafael2 opened this issue May 7, 2024 · 5 comments
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/android 🤖 s/needs-attention Issue has more information and needs another look s/needs-repro Attach a solution or code which reproduces the issue s/no-recent-activity Issue has had no recent activity t/bug Something isn't working

Comments

@DevRafael2
Copy link

DevRafael2 commented May 7, 2024

Description - Translated

When having a CollectionView which has as ItemSource an ObservableCollection it does not reflect changes when modifying properties of any of its Items. The item if it is modified but it is not reflected in the user interface.
I have tried with bidirectional Binding, with the Dispatch, with OnPropertyChange, but nothing works.

Description - Original

Al tener un CollectionView el cual tiene como ItemSource una ObservableCollection este no refleja cambios al modificar propiedades de alguno de sus Ítems. El item si se modifico más no se refleja en la interfaz de usuario.
He intentado con Binding bidireccional, con el Dispatch, con OnPropertyChange, pero nada funciona

Steps to Reproduce - Translated

Create a list in your ViewModel (CollectionView)
Create a CollectionView that uses it <CollectionView ItemSource=“{Binding MyCollection}”>...
Modify some of its Items

Steps to Reproduce - Original

Crea una lista en tu ViewModel (CollectionView)
Crea un CollectionView que la utilice ...
Modifica alguno de sus Ítems

Link to public reproduction project repository

No response

Version with bug

8.0.21 SR4.1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.20 SR4

Affected platforms

Android

Affected platform versions

Solo he probado en Android

Did you find any workaround?

No response

Relevant log output

No response

@DevRafael2 DevRafael2 added the t/bug Something isn't working label May 7, 2024
Copy link
Contributor

github-actions bot commented May 7, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@jsuarezruiz jsuarezruiz added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label May 7, 2024
@PureWeen PureWeen added legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor control-collectionview s/needs-repro Attach a solution or code which reproduces the issue and removed area-controls-collectionview CollectionView, CarouselView, IndicatorView labels May 8, 2024
@drasticactions drasticactions changed the title CollectionView - No cambia la interfaz de usuario al modificar un elemento de un ObservableCollection CollectionView - Does not change the user interface when modifying an ObservableCollection element May 9, 2024
@drasticactions
Copy link
Contributor

I needed to translate your message to understand it, so I may have lost something in this, but I believe this is correct behavior.

An ObservableCollection, I believe, implements INotifyPropertyChanged for the items themselves. If you add a new item, ListView/CollectionView will add a new item to the list, based on the DataTemplate. If you're editing elements within that list, those properties would still need to implement some form of INotifyPropertyChanged for each property. Just having an ObservableCollection doesn't magically make that work.

Having an example of what you're doing would help see if you're implementing this incorrectly.

@Eilon Eilon added area-controls-collectionview CollectionView, CarouselView, IndicatorView and removed control-collectionview legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor labels May 10, 2024
@dotnet-policy-service dotnet-policy-service bot added the s/no-recent-activity Issue has had no recent activity label May 20, 2024
@MSicc
Copy link

MSicc commented May 23, 2024

I am running into similar issues. However, it is not only tied to CollectionView, but happens also with Syncfusion's ListView control. On top, it does not matter if the Itemsource is a List or an ObservableCollection.

In one of my scenarios, I have a boolean that controls the visibility of an ImageButton. This Binding works like it should.

The same boolean is used and runs through 2 converters, one converts the boolean to a Color (predefined Red and Green), the other loads text from the app's resx file. The Color is bound to the BackgroundColor of an Ellipse, while the text is bound to the ToolTipProperties.Text property. These two bindings work only one-time, but do not get changed after that.

If I add a breakpoint in the ctor of my ViewModel, the change gets propagated like it should.

I tested also binding to properties in the ViewModel instead of using the converters, but that does not change anything.

I tried to add Task.Delay between OnPropertyChanged calls with no success.

I also did a clean/rebuild between these changes.

It would be great if someone could take the problem seriosuly.

Tested these on MacCatalyst.

Edit 1:
On SfListView, if I change the CachingStrategy property to CreateNewTemplate, the bindings work. Which just underlines that there seems to be some problem with the DataTemplating in MAUI.

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue s/no-recent-activity Issue has had no recent activity labels May 23, 2024
@jsuarezruiz jsuarezruiz added the s/needs-repro Attach a solution or code which reproduces the issue label Jun 7, 2024
Copy link
Contributor

Hi @DevRafael2. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@dotnet-policy-service dotnet-policy-service bot added the s/no-recent-activity Issue has had no recent activity label Jun 12, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/android 🤖 s/needs-attention Issue has more information and needs another look s/needs-repro Attach a solution or code which reproduces the issue s/no-recent-activity Issue has had no recent activity t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants