Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Redesign the XAML Binding syntax based on Angular/Polymer

$
0
0

XAML is good at describing object trees, but the data binding syntax is very clunky.

For example, let's say you want to show a control if Foo is not null.

Currently, you need really verbose, unintuitive and error-prone syntax like this:

IsVisible="{Binding Foo, Converter={x:Static local:IsNotNullConverter.Instance}}"

However, the syntax could just be this:

IsVisible="{{Foo != null}}"

It's actually pretty easy to implement at least a basic version of this, as all you need is to do is extract the property names from the expression and create a multi-binding referring to a multi-value converter (or single-value in case only one property is mentioned) that would be generated from the expression by the XAML code generator.

Most (or all?) XAML markup extensions can then be obsoleted in favor of extensions to the {{}} syntax: for example, converters could become {{expr | converter}}, x:Reference and StaticResource can become {{$name}}, x:Null is just {{null}}, and so on.

This would be a tremendous improvement in usability and bring Xamarin.Forms XAML syntax to the level of current client-side web frameworks like Angular.js and Polymer (https://www.polymer-project.org/docs/polymer/databinding.html, https://www.polymer-project.org/docs/polymer/expressions.html).


Viewing all articles
Browse latest Browse all 58056

Trending Articles