You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bind to property members on other objects. These objects and properties must be relative to the current scene script.
107
109
@@ -128,6 +130,7 @@ public PlayerData SelectedPlayerData
128
130
```
129
131
</details>
130
132
133
+
<br/>
131
134
132
135
### Formatters
133
136
A binding can be declared with an optional formatter to format the value between your control and the target property or implement custom type conversion. Formatters can also be used to modify list items properties by returning a `ListItem` object.
@@ -156,6 +159,8 @@ This formatter will set a string value into the target control using the input v
156
159
157
160
</details>
158
161
162
+
<br/>
163
+
159
164
### List Binding
160
165
List bindings can be bound to an `ObservableList<T>` to benefit from adding and removing items
161
166
@@ -195,6 +200,8 @@ public class PlayerDataListFormatter : IValueFormatter
195
200
196
201
</details>
197
202
203
+
<br/>
204
+
198
205
### Scene List Binding
199
206
Bind an `ObservableList<T>` to a control's child list to add/remove children. The target scene must have a script attached and inherit from `ObservableNode`. It must also provide an implementation for `SetViewModeldata()`
200
207
@@ -226,3 +233,80 @@ public partial class PlayerDataListItem : ObservableNode
226
233
}
227
234
```
228
235
</details>
236
+
237
+
<br/>
238
+
239
+
### Control input validation
240
+
Control bindings can be validated by either:
241
+
* Adding validation function to the binding
242
+
* Throwing a `ValidationException` from a formatter
243
+
244
+
There also two main ways of subscribing to validation changed events:
245
+
* Subscribe to the `ControlValidationChanged` event on the `ObservableNode` your bindings reside on
246
+
* Add a validation handler to the control binding
247
+
248
+
You can also use the `HasErrors` property on an `ObservableNode` to notify your UI of errors and review a full list of validation errors using the `GetValidationMessages()` method.
249
+
250
+
251
+
<details>
252
+
<summary>details</summary>
253
+
<br/>
254
+
255
+
**Adding validators and validation callbacks**
256
+
257
+
Property bindings implement a fluent builder pattern for modify the binding upon creation to add validators and a validator callback.
258
+
259
+
You can have any number of validators but only one validation callback.
260
+
261
+
Validators are run the in the order they are registered and validation will stop at the first validator to return a non-empty string. Validators are run before formatters. The formatter will not be executed if a validation error occurs.
262
+
263
+
This example adds two validators and a callback to modulate the control and set the tooltip text.
**Subscribing to `ControlValidationChanged` events**
276
+
277
+
If you want to have common behaviour for many or all controls, you can subscribe to the `ControlValidationChanged` event and get updates about all control validations.
278
+
279
+
This example subscribes to all validation changed events to modulate the target control and set the tooltip text.
280
+
281
+
The last validation error message is also stored in the local ErrorMessage property to be bound to a UI label.
0 commit comments