-
Notifications
You must be signed in to change notification settings - Fork 377
MvvmCross Native controls
Daniel Luberda edited this page Apr 27, 2019
·
1 revision
MvxCachedImageView
allows you to easily integrate with MvvmCross.
This helper is included in the Nuget packages.
_imageControl = new MvxCachedImageView();
ContentView.AddSubview(_imageControl);
ContentView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
SetNeedsUpdateConstraints();
this.DelayBind(
() =>
{
_imageControl.LoadingPlaceholderImagePath = "res:place.jpg";
_imageControl.ErrorPlaceholderImagePath = "res:place.jpg";
_imageControl.TransformPlaceholders = true;
var set = this.CreateBindingSet<CustomTableViewCell, Image>();
set.Bind(_imageControl).For(v => v.DownsampleWidth).To(vm => vm.DownsampleWidth);
set.Bind(_imageControl).For(v => v.Transformations).To(vm => vm.Transformations);
set.Bind(_imageControl).For(v => v.ImagePath).To(vm => vm.Url);
set.Apply();
}
);
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ffimageloading.cross.MvxCachedImageView
android:layout_width="match_parent"
android:layout_height="100dp"
local:MvxBind="LoadingPlaceholderImagePath 'res:place.jpg'; ErrorPlaceholderImagePath 'res:place.jpg'; Transformations Transformations; DownsampleWidth DownsampleWidth; ImagePath Url" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
local:MvxBind="Text Url" />
</LinearLayout>