[mono-android] Anyone interested in Silverlight style DataBinding for Droid?

Stuart Lodge me at slodge.com
Tue Feb 21 19:39:06 UTC 2012


If anyone else out there is porting from WP7 to Droid and is looking for
some MonoDroid Databinding code, then I've posted some as part of MvvmCross
over on GitHub - https://github.com/slodge/MvvmCross/wiki/Tutorial

The full story is quite long... but the short story is that the code lets
you add JSON databinding statements to your axml like:

 <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    local:MvxBind="{'Text':{'Path':'TheText','Converter':'StringReverse'}}"
    />

which means that your Android View C# code can be entirely empty and that
you can reuse some of your value converters across wp7 and droid...

There's also a MT version of this which works on some MonoTouch.Dialog
elements - e.g.

          this.Root = new RootElement("Simple Text Property")
                          {
                              new Section("Display")
                                  {
                                      new
StringElement("Current").Bind(this, "{'Value':{'Path':'TheText'}}"),
                                      new
StringElement("Length").Bind(this,
"{'Value':{'Path':'TheText','Converter':'StringLength'}}"),
                                      new
StringElement("Reversed").Bind(this,
"{'Value':{'Path':'TheText','Converter':'StringReverse'}}"),
                                  },
                              new Section("Editing")
                                  {
                                      new
EntryElement("Edit").Bind(this, "{'Value':{'Path':'TheText'}}"),
                                  },
                          };


As I say... The full story is quite long, its related to some of the
MonoCross MVC work, and it's tied to a project I've been on for the last 3
months. This open source part I'm writing it up as I get bits of spare
time.... which isn't very often!

Stuart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monodroid/attachments/20120221/3922fcf8/attachment-0001.html>


More information about the Monodroid mailing list