1
votes

I inherited a Xamarin MVVMCross project from another developer. I was wondering how can I get the default binding mode used and how I can change it.

1

1 Answers

1
votes

In MvvmCross the default binding mode is usual Two-Way when using bindings defined by MvvmCross (Virtual property bindings/Custom bindings). Native properties will usual be One-Way as by default there is no return mechanism (View to ViewModel).

Notes from MvvmCross Custom binding:

Where MvvmCross had created new bindings, then this [Two-Way binding] is very often the default binding mode MvvmCross tries to use.

With the exception being Windows and Xaml:

In Windows/Xaml, this [One-Way binding] is very often the default binding mode - so it is the mode used when no other is selected.

Swiss binding syntax

, Mode=$WhichMode$

where $WhichMode$ is one of:

  • OneWay
  • OneWay
  • ToSource
  • TwoWay
  • OneTime
  • Default

Example using Android AXML

local:MvxBind="Text UserName, Mode=OneWay"

Fluent binding syntax

Using code base binding you can use:

OneWay()
TwoWay()
OneWayToSource()
OneTime()

Example:

var set = this.CreateBindingSet<MyView, MyViewModel>();
set.Bind(cardLabel)
    .For(v => v.Text)
    .To(vm => vm.UserName)
    .OneWay();
set.Apply();