fabulous-dev / Fabulous

Declarative UI framework for cross-platform mobile & desktop apps, using MVU and F# functional programming
https://fabulous.dev
Apache License 2.0
1.15k stars 122 forks source link

Add ViewRef support in ListView/CollectionView #779

Closed TimLariviere closed 4 years ago

TimLariviere commented 4 years ago

Closes #653

This PR adds support for ViewRef in ListView/CollectionView. It is now possible to retrieve the actual XF instance of a cell with ViewRef.

let secondLabelRef = ViewRef<Label>()

View.CollectionView([
    View.Label()
    View.Label(ref = secondLabelRef)
    View.Label()
])

Note that created is not supported and won't be in the future, the reason is the list is virtualized so XF works with a small set of cells and automatically reuses them when scrolling. Hence there is no specific moment when the second label is "created".