[NET 8, RC1, Windows] wrong initial BindingConext in CollectionView DataTemplate #17515
Labels
area-controls-collectionview
CollectionView, CarouselView, IndicatorView
platform/windows 🪟
t/bug
Something isn't working
Description
The BindingContext for DataTemplates in CollectionView seems to be broken in .NET 8 RC1. Upon loading the CollectionView Items, the template object initially receives BindingContex reference to the BindingContext of the CollectionView parent. Immediately after it receives another BindingContext reference - this time the right reference to the Model of Items. This behavior has big performance impact because it sets Bindings twice and causes BindingFailures during the first cycle.
Note: I can see the data but a run time exception will occur whenever the button command is executed that is bounded to the view model.
Tested on Windows and Windows subsystem for Android - only Windows version seems affected.
Steps to Reproduce
Warnings List:
Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics: Warning: 'Title' property not found on 'CollectionViewIssue.MainPageViewModel', target property: 'Microsoft.Maui.Controls.Label.Text'
Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics: Warning: 'Program' property not found on 'CollectionViewIssue.MainPageViewModel', target property: 'Microsoft.Maui.Controls.Label.Text'
Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics: Warning: 'Course' property not found on 'CollectionViewIssue.MainPageViewModel', target property: 'Microsoft.Maui.Controls.Label.Text'
Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics: Warning: 'EndDate' property not found on 'CollectionViewIssue.MainPageViewModel', target property: 'Microsoft.Maui.Controls.Label.Text'
Runtime fatal exception:
Exception = {"Parameter "parameter" (object) cannot be of type CollectionViewIssue.MainPageViewModel, as the command type requires an argument of type CollectionViewIssue.Assessment. (Parameter 'parameter')"}
Note: This 100% works without any issues on Android, its only happening on windows.
Link to public reproduction project repository
https://github.com/malsabi/CollectionViewIssue
Version with bug
8.0.0-rc.1.9171
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
7.0.92
Affected platforms
Windows
Affected platform versions
Windows SDK 10.0.19041.0
Did you find any workaround?
All the .NET 7 builds seem working properly, including nightly releases.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: