2013-10-18 52 views
1

我有一个iOS预约应用程序运行Xamarin Studio中的Mono 2.10.11。MVVMCross界限按钮事件不会触发按

约会详细信息屏幕允许约会根据他们的结果进行评分。基于业务逻辑的布尔集合显示允许评级的按钮。绑定的按钮触发打开评级屏幕。它可以在iOS 6.1的Mobile和Debugger以及iOS 7模拟器上正常运行。它不适用于iOS 7设备。

的AppointView.cs包含函数的viewDidLoad其如下设置按钮: -

AppointmentViewTable.Source = _source; 

this.AddBindings (new Dictionary<object, string> 
{ 
    { _source, "{'ItemsSource':{'Path':'AppointmentDetails'}, 'HeaderTitle':{'Path':'Appointment.AppointmentDate','converter':'DateTime'}}" }, 
    { btnRateSession, "{'Hidden':{'Path':'Appointment.RateAvailable','converter':'InvertedVisibility'}, 'Title':{'Path':'TextSource','Converter':'Language','ConverterParameter':'btnRateSession'}, 'TouchDown':{'Path':'GoToSessionRateView'}}"} 
}); 

通过创建约会看法,我得到以下警告的运行程序: -

2013-10-18 16:58:55.012 M2FitiOS[3773:a0b] MvxBind: Error: 14.12 Problem seen during binding execution for from Appointment.RateAvailable to Hidden - problem InvalidCastException: Null object can not be converted to a value type. 
at System.Convert.ToType (System.Object value, System.Type conversionType, IFormatProvider provider, Boolean try_target_to_type) [0x00017] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Convert.cs:2553 
at System.Convert.ChangeType (System.Object value, System.Type conversionType, IFormatProvider provider) [0x00017] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Convert.cs:2204 
at Cirrious.MvvmCross.Binding.ExtensionMethods.MvxTypeExtensions.MakeSafeValue (System.Type propertyType, System.Object value) [0x00000] in <filename unknown>:0 
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 

该AppointmentViewModel包含事件: -

public ICommand GoToSessionRateView 
{ 
    get 
     { 
      return new MvxRelayCommand(() => RequestNavigate<SessionRateViewModel>(new { appointmentId = _appointmentId })); 
     } 
    } 

ñ确定是什么原因导致该事件停止工作。任何指针将不胜感激。

+0

有些东西是空的。修复。另外我会推荐使用最新版本的MvvmCross。 – Cheesebaron

回答

4

一般的东西不工作的设备是由于Xamarin“接头”,可以围绕使用多种选项的工作 - 看Trouble with xamarin.ios/monotouch , mvvmcross and linking

发生这种情况时我的首选方案是使用LinkerPleaseInclude.cs文件 - 像https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/ApiExamples/ApiExamples.Touch/LinkerPleaseInclude.cs

如果这是你的情况的问题,那么你就需要确保LinkerPleaseInclude包括TouchDown参考 - 尽管你可能会更快乐,如果你确实改变结合TouchUpInside代替。


同时,你有痕迹显示错误在Appointment.RateAvailable to Hidden - 我很困惑,为什么这应该是在ios7不同。我怀疑在这个旧版本的MvvmCross中解决这个问题的最简单方法可能是升级......虽然也可以将converter更改为Converter,这可能会有所帮助。

+0

感谢您的建议。建立并开始升级。 – Gaius