I'm developing an app with Xamarin and MVVMCross and I'm having problems creating binding NSLayoutConstraints constants.
I have a view with a Subview that should "disapear" if a certain List<> has no elements, and the content below should move up instead of leaving it's space empty.
To do that I added an NSLayoutConstraint to this view to be able to modify it's height programmatically and I bind it with the following line of code:
var set = this.CreateBindingSet<ActivityView, ActivityViewModel> ();
set.Bind (ConstraintHeightPictures).To (vm => vm.Activity.ImageList.Count).For (cons => cons.Constant).WithConversion ("CountToConstraintHeight", Constants.HeightActivityImages);
set.Apply ();
The CountToConstraintHeightConverter is pretty simple, it just checks if the value is equal to 0 to return 0 or otherwise the default height value (Constants.HeightActivityImages).
The code gives no execution error and passes through the Converter but when I run the app, the View is still there, empty.
On the other hand if I run the following line of code inside ViewWillLayoutSubviews
it works perfectly but it's not binded.
ConstraintHeightPictures.Constant = ViewModel.Activity.ImageList.Count > 0 ? Constants.HeightActivityImages : 0.0f;
Any ideas?
Many thanks in advance!
Jordi