class MyApp: App(MainView::class) { val mainViewViewModel : MainViewViewModel by inject() override fun start(stage: Stage) { super.start(stage) mainViewViewModel.startupTasks() } } class MainViewViewModel : ViewModel() { val libraryViewModel:LibraryViewModel by inject() fun startupTasks(){ //imagine we're loading this from local drive... var newLibrary = ShapeLibrary() newLibrary.name = "My library" var someShape = ShapeItem("Shape 1", "some SVG path") var someShape2 = ShapeItem("Shape 2", "some other SVG path") newLibrary.shapesProperty.addAll(listOf(someShape, someShape2)) libraryViewModel.item = newLibrary } } class MainView : View("FlowTest") { override val root = splitpane { prefHeight = 800.0 prefWidth = 1200.0 stackpane { style { backgroundColor = multi(Color.GREEN) } button ( "Some ui controls will go here") } stackpane { style { backgroundColor = multi(Color.BLUE) } add(LibraryView::class) { vgrow = Priority.ALWAYS hgrow = Priority.ALWAYS } } } } class LibraryView : View("Current Library") { val shapeLibraryViewModel : LibraryViewModel by inject() override val root = anchorpane{ vbox{ label(shapeLibraryViewModel.name) } flowpane { bindChildren(shapeLibraryViewModel.libraryItemsProperty){ shapeItem -> button(shapeItem.name) } } } } class LibraryViewModel : ItemViewModel(){ val name = bind(ShapeLibrary::nameProperty) val libraryItemsProperty : SimpleListProperty = bind(ShapeLibrary::shapesProperty) } class ShapeLibrary{ val nameProperty = SimpleStringProperty() var name by nameProperty val shapesProperty = SimpleListProperty(FXCollections.observableArrayList(arrayListOf())) var shapes by shapesProperty } class ShapeItem(name:String, path:String){ val nameProperty = SimpleStringProperty() var name by nameProperty val pathProperty = SimpleStringProperty() var path by pathProperty }