class MainView : Fragment("My View") { val expandedState: ExpandedStateHolder by inject() override val root = listview(listOf(Category("A"), Category("B")).observable()) { cellCache { TitledPane(it.name, listview(it.components) { prefHeight = 200.0 cellCache { stackpane { this += ComponentView(it.name) } } }).apply { val expandedState = expandedState.categoryExpanded(it.name) isExpanded = expandedState.value expandedState.cleanBind(expandedProperty()) } } } }