maui
maui copied to clipboard
BindingList-BindableLayout not updating
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
- Create a VerticalStackLayout with a BindableLayout
- Bind the ItemsSource of the BindableLayout to a BindingList
- Add items to the BindingList
Optionally you can do the same with an ObservableCollection. Then it works.
Link to public reproduction project 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
❌
Does BindingList
implement INotifyCollectionChanged
? The BindingList won't update if it doesn't implement INCC
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.
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>
.
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).
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.
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:
Android:
- Starting the app in Portrait mode
- Rotating into Landscape mode
- Press the Button
- Rotating back into Portrait mode