When you use DataTemplateSelector with HasUnevenRows you may occur error Specified cast is invalid on iOS.
I've found easy scenario to reproduce (see attached repository).
You have to have at least two Data templates and at least one of them should have Label directly under ViewCell. In such case when you alter ItemsSource from second DataTemplate to this one, error will crash your application.
Steps to Reproduce
Run project on iOS from attached reproduction repository
Tap button couple times until you change from data template with image to data template with only label
Verified this on VS 17.10.0 Preview 1.0(8.0.6). Repro on iOS 17.2 and MacCatalyst, not repro on Windows 11 and Android 14.0-API34 with below Project:
maui-dts-unevenrows-issue.zip
Description
When you use
DataTemplateSelector
withHasUnevenRows
you may occur errorSpecified cast is invalid
on iOS.I've found easy scenario to reproduce (see attached repository). You have to have at least two Data templates and at least one of them should have
Label
directly underViewCell
. In such case when you alterItemsSource
from secondDataTemplate
to this one, error will crash your application.Steps to Reproduce
Link to public reproduction project repository
https://github.com/jpiechowiak/maui-dts-unevenrows-issue
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
-
Did you find any workaround?
In ViewCell which contains only label, wrap
Label
with container - for instance inStackLayout
Relevant log output
No response