This new work all applies within the heart of MvvmCross data-binding. As many of you know, earlier this year we rewrote the binding engine in MvvmCross to use the simpler, cleaner 'Swiss' binding. More recently, we've now been working hard to extend this clean 'Swiss' syntax in some new directions - and this work is codenamed Tibet
Some of the motivation behind Tibet was the work we've already done, but beyond that we've also received some really valuable ideas and input from users and from community comments, including blog posts like "Knockout - what Mvvm should have been like in Xaml"
We hope that the output of Tibet will allow us to databind to viewmodels using a richer syntax including:
- Function-like value converter calling
- Multi-bindings - allowing a single UI field to update in response to any of several ViewModel property changes
- The use of literals (ints, doubles, booleans and strings) within the bindings.
- Simple operator syntax which can be applied across multi-bindings - note that these operations are *not* full .Net operators - instead they just provide a simple interpreter
- Nested application of operators and value converters - allowing you to use multiple bindings and multiple value converters within the same binding expression.
- The unification of binding so that the same engine and syntax is used across all platforms (across all of Windows, Android and iOS)
As an example of the syntax we can build, I've recorded this short introduction:
Within this introduction we build up to a 'complicated' and 'artificial' binding of:
Text Salutation(Counter + Length(Hello)) + ' ' + Hello
This binding says that the value of Text should be dynamically calculated by:
- applying the LengthValueConverter to the Hello property
- adding the value of the Counter property
- applying the SalutationValueConverter to that sum
- concatenating the resulting string with a single space
- concatenating the resulting string with the value of the Hello property
The basis for this demo code today is a simple ViewModel and 2 simple ValueConverters:
The binding in Android then looks like:
The binding within iOS is similar. Note that we don't yet use the Fluent binding for this new binding, although we would hope to add some fluent code for it in the future:
The binding within Windows is:
I've pushed the code for this first demo to: https://github.com/slodge/Tibet
That's all there is for now.
As I said at the start this is an early preview of a new idea, and I'm especially interested to hear:
- whether it's worthwhile continuing...
- whether anyone has any further requirements, ideas or code they'd like to contribute.
Please do let me know if you have any comments :)