Access individual item template binding context during composition #323
wesleykuhn
started this conversation in
New Feature Discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently when working with CollectionView, I do something like this for my templates:
new CollectionView().ItemTemplate(new DataTemplate(() => new VerticalStackLayout() ... ))
However, when I need to send the clicked item as argument I need to do it via Command:
Another problem is when having to render/compose different according to the bindingContext. E.g.: BackgroundColor, text formatting, which style to use, etc. For that, right now we have the template selector, which in my opnion is kindda uncomfortable to use.
The binding way is perfect, but, when I need something more complex I need to use the converter, and that's another problem: Converters everywhere on the app.
Wouldn't be great if we can access the binding context of the dataTemplate inside a composition method? Something like the below example:
And on the page/component file it can be called something like this:
I think there's a lot of thing we can do with the BindingContext on our hands.
My code might be not that great, but the concept is already used on Android's Jetpack Compose and it's great for us devs.
Edit 2024/11/19
I did some refactors on the code that I wrote...
Item template content itself:
Data template:
Usage:
And, at the page:
Beta Was this translation helpful? Give feedback.
All reactions