0

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?

El0din
  • 3,208
  • 3
  • 20
  • 31
  • I would recommend to add one more property to your ViewModel which will represent the union state of "property1 & property2". Then your bindings will be much cleaner – Vitalii Ilchenko Aug 26 '19 at 13:32
  • That was my solution, but my team project is against that, don't want to use another property if the view can control that... – El0din Aug 26 '19 at 15:05

1 Answers1

3

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

Vitalii Ilchenko
  • 578
  • 1
  • 3
  • 7