maui icon indicating copy to clipboard operation
maui copied to clipboard

BindingList-BindableLayout not updating

Open szv opened this issue 2 years ago • 5 comments

Description

When using a BindingList as an ItemSource of a BindableLayout, changes being made in the BindingList don't get reflected in the BindableLayout.

v6.0.540

Steps to Reproduce

  1. Create a VerticalStackLayout with a BindableLayout
  2. Bind the ItemsSource of the BindableLayout to a BindingList
  3. Add items to the BindingList

Optionally you can do the same with an ObservableCollection. Then it works.

Link to public reproduction project repository

Github Repository

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows, I was not able test on other platforms

Affected platform versions

Tested on Windows 11 and Android 12.1 (Emulator)

Did you find any workaround?

Using an ObservableCollection instead is possible. In some cases a BindingList might be more convenient though.

Relevant log output

szv avatar Oct 08 '22 20:10 szv

Does BindingList implement INotifyCollectionChanged ? The BindingList won't update if it doesn't implement INCC

PureWeen avatar Oct 11 '22 18:10 PureWeen

Hi @szv. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. 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.

ghost avatar Oct 11 '22 18:10 ghost

BindingList looks like an old API (it has been available since NET Framework 2.0 and the interface IBindingList has been around since 1.0 apparently).

BindingList<T>: https://apisof.net/catalog/f0abaf55-4ca7-cc12-8a0c-d2ccb5c7b553 IBindingList: https://apisof.net/catalog/edd188ab17a306d1eac8d67f03b819fd

I've never seen it used, and would guess it has been supplanted by INotifyCollectionChanged (and it's common implementation ObservableCollection<T>.

GalaxiaGuy avatar Oct 12 '22 17:10 GalaxiaGuy

BindingList does not implement INotifyCollectionChanged. Nevertheless in WinUI and WPF it works as expected.

I know that BindingList is quite old and ObservableCollection is more common, but ObservableCollection is also quite old and in some situations the BindingList might be convenient though. https://learn.microsoft.com/en-us/dotnet/api/system.collections.objectmodel.observablecollection-1?view=net-7.0#applies-to vs https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.bindinglist-1?view=net-7.0#applies-to

The BindingList forwards INotifyPropertyChanged-events and with ObservableCollection I need to handle the events myself (which is also ok for me).

szv avatar Oct 12 '22 18:10 szv

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.

ghost avatar Oct 13 '22 18:10 ghost

Verified this on Visual Studio Enterprise 17.7.0 Preview 1.0. This issue works on iOS 16.4, but some layout issues on Android 13.0-API33. MauiViewUpdateBug.zip

iOS: Rotate

Android:

  1. Starting the app in Portrait mode image
  2. Rotating into Landscape mode image
  3. Press the Button image
  4. Rotating back into Portrait mode image

XamlTest avatar May 31 '23 06:05 XamlTest