我似乎无法让图像在MvxListView挣扎与MvvmCross
这里正确绑定是模板:
<?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="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Mvx.MvxImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="10dp"
local:MvxBind="ImageUrl IconName, Converter=IconSource" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="30dp"
local:MvxBind="Text Name" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
local:MvxBind="Text Description" />
</LinearLayout>
</LinearLayout>
这里是转换器:
public class IconSourceValueConverter : MvxValueConverter<string, string>
{
protected override string Convert(string value, Type targetType, object parameter, CultureInfo culture)
{
//string retval = string.Format("res:{0}", value.ToLower());
string retval = string.Format("@drawable/{0}", value.ToLower());
return retval;
}
}
所有图像出现在Drawable文件夹中。
我试过drawable和res都没有工作。
我用一个普通的ImageView替换了MvxImageView,它包含一个硬编码的android:src,它工作正常。
任何想法?
working.Tried我似乎总是把这些东西弄明白我已经发布了一个问题刚过!我错过了文件和下载缓存插件。转换器应该使用res:不可绘制。当我被允许时,我会回答我自己的问题。 –
除了'res:'fix之外,您还可以使用自定义绑定目标'DrawableId'作为int或'DrawableName'而不是'ImageUrl' - 这些都是在https:// github中设置时注册的。 com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/Cirrious.MvvmCross.Binding.Droid/MvxAndroidBindingBuilder.cs#L103并使用https://github.com/MvvmCross/MvvmCross/blob/v3.1中的代码实现/Cirrious/Cirrious.MvvmCross.Binding.Droid/Target/MvxImageViewDrawableNameTargetBinding.cs#L38 – Stuart