How do I use MvxImageView.DefaultImagePath?

android, mvvmcross

Solution

If this view is just being used once (e.g. not reused in a list) then you can just use `android:src` for your default image.

If you need to use DefaultImagePath then you can do this in a binding:

 local:MvxBind="ImageUrl ProfileThumbnailImageUrl; DefaultImagePath DefaultImageUrl"

where `DefaultImageUrl` is a drawable accessed as `res:name` - e.g. `res:ic_action_user`, a file path (saved using the File plugin), or an http url

You should also be able to do this as a string literal:

 local:MvxBind="ImageUrl ProfileThumbnailImageUrl; DefaultImagePath 'res:ic_action_user'"

Problem

I have successfully used `MvxImageView` with `ImageUrl`, but how can I set a drawable icon as a default for those users which don't have a profilepicture (that is, where ProfileThumbnailImageUrl is empty)? ``` <MvxImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_alignParentLeft="true" local:MvxBind="ImageUrl ProfileThumbnailImageUrl" DefaultImagePath="@drawable/ic_action_user"/> ```

Original source