Aga*_*gat 2 data-binding touch mvvmcross
我在非常简单的情况下使用MvxImageViewLoader.
在ViewDidLoad上:
var pnlBackImage = new UIImageView(new RectangleF(0, 0, pnlBack.Frame.Width, pnlBack.Frame.Height));
Add(pnlBackImage);
pnlBackImageLoader = new MvxImageViewLoader(() => pnlBackImage);
...
set.Bind(pnlBackImageLoader).To(x => x.UserBackgroundUrl);
Run Code Online (Sandbox Code Playgroud)
UserBackgroundUrl是一个常见的字符串属性.
但是在set.Apply()上,我在日志中看到以下内容并且图片未加载:
2013-06-24 13:51:26.999 SPBTouch[446:21b03] MvxBind: Error: 2.78 Problem seen during binding execution for from UserBackgroundUrl to ImageUrl - problem TargetInvocationException: Exception has been thrown by the target of an invocation.
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000d9] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:236
at System.Reflection.MonoProperty.SetValue (System.Object obj, System.Object value, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] index, System.Globalization.CultureInfo culture) [0x00064] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoProperty.cs:353
at System.Reflection.PropertyInfo.SetValue (System.Object obj, System.Object value, System.Object[] index) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/PropertyInfo.cs:93
at Cirrious.MvvmCross.Binding.Bindings.Target.MvxPropertyInfoTargetBinding.SetValue (System.Object value) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.UpdateTargetFromSource (Boolean isAvailable, System.Object value) [0x00000] in <filename unknown>:0
InnerException was NullReferenceException: Object reference not set to an instance of an object
at Cirrious.MvvmCross.Binding.Views.MvxBaseImageViewLoader`1[MonoTouch.UIKit.UIImage].set_ImageUrl (System.String value) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000c0] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:228
Run Code Online (Sandbox Code Playgroud)
我甚至将图像加载器甚至图像面板定义为视图字段,但仍然没有运气.什么可能导致这个问题?
谢谢.
您列出的内部异常错误是:
NullReferenceException:对象引用未设置为Cirrious.MvvmCross.Binding.Views.MvxBaseImageViewLoader`1 [MonoTouch.UIKit.UIImage] .set_ImageUrl(System.String value)[0x00000] in中对象的实例:0
我想这将导致一个东西NullReferenceException在set的:
public string ImageUrl
{
get { return _imageHelper.ImageUrl; }
set { _imageHelper.ImageUrl = value; }
}
Run Code Online (Sandbox Code Playgroud)
如果_imageHelper是null
查看MvxBaseImageViewLoader.cs#L31如果显示此错误消息,则会发生这种情况Unable to resolve the image helper - have you referenced and called EnsureLoaded on the DownloadCache plugin?
是否显示此错误消息?如果是这样,你的应用程序中是否加载了DownloadCache插件(以及它的依赖插件File)?
如果这没有帮助,请尝试比较您的应用,以便N + 1中的某些应用.几个N + 1视频 - http://mvvmcross.wordpress.com/ - 涵盖了图像视图的成功使用- 例如N = 2或N = 3