Search code examples
c#androidmvvmcrossvalueconvertermvxbind

MVVMCross MvxBind, binding multiple values to one property


How do I use a combination of booleans values, to set the enabled property on a MvxBind button?

For example:

Using one boolean value, the binding is achieved with:

<Button
      android:text="Next"
      local:MvxBind="Enabled IHaveDoneEverything"/>

But how do I implement this using multiple boolean values?

Things I've tried that didn't work:

  • Using an OR statement in axml. local:MvxBind="Enabled (IHaveDoneThis | IHaveDoneThat)"
  • Using an extra property in my ViewModel. This didn't work due to the property not being 'set' and thus not being updated in the view.

    public bool IHaveDoneAtleastSomething 
    { 
        get { return (IHaveDoneThis | IHaveDoneThat); } 
    }
    
  • Using a custom valueconverter.

    local:MvxBind="Enabled [IHaveDoneThis , IHaveDoneThat], Converter=MultipleBooleansToOneBooleanUsingORValueConverter"/>

Solution

  • Using || instead of | actually resolved this issue.

    local:MvxBind="Enabled (IHaveDoneThis || IHaveDoneThat)"