0
votes

Any possibility to use more than one conversion for MvvmCross one binding?

For ex.:

this.CreateBinding(UIImage)
                .For(i => i.Image)
                .To((ViewModel model) => model.IsFavourite)
                .WithConversion(new BooleanToFavouriteImageConverter(), null)
                .WithConversion(new ImageToImageFromBundleConverter(), null)
                .Apply();

IsFavourite is bool property, which I want to convert to an image and after that set and the image as a bundle resource?

1

1 Answers

0
votes

You can always combine the two ValueConverters in a new class.

Create a BooleanToImageFromBundleConverter that uses BooleanToFavouriteImageConverter and ImageToImageFromBundleConverter.

By doing this you use two converters only in a different way.

this.CreateBinding(UIImage)
                .For(i => i.Image)
                .To((ViewModel model) => model.IsFavourite)
                .WithConversion(new BooleanToImageFromBundleConverter(), null)
                .Apply();

At last if you want to extend this behaviour, lets say you got multiple types of images that you want to convert from boolean.

Try using the object parameter and create a statement that uses a different value ValueConverter.

.WithConversion(new BooleanToImageFromBundleConverter(), "Favorite")