xamarinxamarin.iosmvvmcrossxamarin.ios-binding

How combine multiple visibility properties binding (fluent) in MvvmCross for iOS?


i want to combine these 2 properties:

set.Bind(myObject).For("Visibility").To(vm => vm.property1).WithConversion("Visibility");
set.Bind(myObject).For("Visibility").To(vm => vm.property2).WithConversion("Visibility");

I read something like this for Android

local:MvxBind="Visibility Visibility(And(property1, property2))"

But don't know how to translate to fluent, how can i do?


Solution

  • There are at least two ways to do it:

    set.Bind(textField)
       .For(t => t.Hidden)
       .To($"{nameof(FooViewModel.property1)} && {nameof(FooViewModel.property2)}");
    

    and

    set.Bind(textField)
       .For(t => t.Hidden)
       .ByCombining("And", vm => vm.property1, vm => vm.property2);
    

    In the second example the register of And keyword is important.

    Both options give the same result: textField will be hidden only if both property1 and property2 are equal true