Closed forTribeforXuanmo closed 5 years ago
In JavaFX there are two ways to bind properties:
bind
method. They support data-flow only in one direction. Based on your description I assume that you've used a unidirectional binding from the model-value to the textfield like this:
textfield.textProperty().bind(viewModel.modelValueProperty());
Then the value can only go from the model to the view and not the other way around. Instead you should use a bi-directional binding like this:
textfield.textProperty().bindBidirectional(viewModel.modelValueProperty());
unidirectional bindings are useful if the target-property isn't changed by the user. For example the disableProperty
of Controls can be bound this way so that the viewModel provides a (read-only) boolean-property for this.
when i bind model data to TextField ,the textfield cant edit , because the data mode Initialized in the java code, i cant edit the input textfield , in the beginning ,i think it like js framework "vue" can bind view and data double-sided, Is it that I used it wrong? expecting a reply !