MvxImageView, can't bind ImageUrl to local resource
mvvmcross, xamarin.android
Solution
The problem was only capitalization in the resource name. Although the image filename starts with a capital C, and the android:src attribute works with a capital C, the MvxBind of ImageUrl requires a lowercase c:
<Mvx.MvxImageView
android:layout_width="100dp"
android:layout_height="75dip"
android:layout_weight="1"
local:MvxBind="ImageUrl 'res:card_kh'"/>
This also solves the problem when the source of the ImageUrl value is a viewmodel property:
class MyViewModel : MvxViewModel
{
public string SomeImagePath { get { return "res:card_kh"; } }
}
and
<Mvx.MvxImageView
android:layout_width="100dp"
android:layout_height="75dip"
android:layout_weight="1"
local:MvxBind="ImageUrl SomeImagePath"/>
Problem
I'm using MvvmCross 3.0.14 with Xamarin.Android. I have an MvxImageView that I can get to display a particular local graphics resource if I specify the image directly (without binding) using android:src: ``` <Mvx.MvxImageView android:layout_width="100dp" android:layout_height="75dip" android:layout_weight="1" android:src="@drawable/Card_kh"/> ``` But I can't get the same image to show up using local:MvxBind: ``` <Mvx.MvxImageView android:layout_width="100dp" android:layout_height="75dip" android:layout_weight="1" local:MvxBind="ImageUrl 'res:Card_kh'"/> ``` This does not work. MvxAndroidLocalFileImageLoader.LoadResourceBitmap logs a trace message indicating that 'Card_kh' was not a known drawable name. It's encouraging that it got that far -- at least I know that the intended consumer of this information did get it. But apparently I have not provided that information in the correct format. Taking it one step further, my actual goal is to have my ViewModel determine what resource should be used, e.g. ``` class MyViewModel : MvxViewModel { public string SomeImagePath { get { return "res:Card_kh"; } } } ``` and ``` <Mvx.MvxImageView android:layout_width="100dp" android:layout_height="75dip" android:layout_weight="1" local:MvxBind="ImageUrl SomeImagePath"/> ``` What do I need to do to have an MvxImageView bind to a view-model determined local resource image?