将我的项目更新为Unified API和MVVM Cross 3.5 stable之后,我在控制台中收到以下warring消息,表示所有按钮绑定...
我这样绑定。
try {
this.AddBindings(
new Dictionary < object, string > () {
//all the command controls - such as buttons
{
btnXmit,
"TouchUpInside cmdXmitClicked"
}, {
btnCancel,
"TouchUpInside cmdBack"
},
});
} catch (Exception error) {
}
at
Cirrious.CrossCore.WeakSubscription.MvxWeakEventSubscription
2[System.Windows.Input.ICommand,System.EventArgs]..ctor (ICommand source, System.Reflection.EventInfo sourceEventInfo, System.EventHandler
1 targetEventHandler)[0x00028] /Volumes/WORKSPACE/Workspace/V3.5/framework/framework/MvvmCross-3/CrossCore/Cirrious.CrossCore/WeakSubscription/MvxWeakEventSubscription的.cs:52 在/Volumes/WORKSPACE/Workspace/V3.5/framework/framework/MvvmCross-3/CrossCore中的Cirrious.CrossCore.WeakSubscription.MvxCanExecuteChangedEventSubscription..ctor(ICommand source,System.EventHandler1 eventHandler) [0x00000] in /Volumes/WORKSPACE/Workspace/V3.5/framework/framework/MvvmCross-3/CrossCore/Cirrious.CrossCore/WeakSubscription/MvxCanExecuteChangedEventSubscription.cs:21 at Cirrious.CrossCore.WeakSubscription.MvxWeakSubscriptionExtensionMethods.WeakSubscribe (ICommand source, System.EventHandler
1 eventHandler)[0x00003] /Cirrious.CrossCore/WeakSubscription/MvxWeakSubscriptionExtensionMethods.cs:68 在Cirrious.MvvmCross.Binding.Touch.Target.MvxUIControlTouchUpInsideTargetBinding.SetValueImpl(System.Object target,System.Object value)[0x00045] in /Volumes/WORKSPACE/Workspace/V3.5/framework/framework/MvvmCross-3/Cirrious/ Cirrious.MvvmCross.Binding.Touch /目标/ MvxUIControlTouchUpInsideTargetBinding.cs:74 在/Volumes/WORKSPACE/Workspace/V3.5/framework/framework/MvvmCross-3/Cirrious/Cirrious.MvvmCross.Binding中的Cirrious.MvvmCross.Bindings.Bindingget.Marx.MvxConvertingTargetBinding.SetValue(System.Object value)[0x000bd] /Bindings/Target/MvxConvertingTargetBinding.cs:64 在Cirrious.MvvmCross.Bindings.Bindings.MvxFullBinding.UpdateTargetFromSource(System.Object value)[0x00036] in /Volumes/WORKSPACE/Workspace/V3.5/framework/framework/MvvmCross-3/Cirrious/Cirrious.MvvmCross.Binding/Bindings /MvxFullBinding.cs:162 2015-02-16 17:48:14.433 RemoteInspectioniOS [3506:119564] MvxBind:错误:212.37绑定执行绑定TouchUpInside for cmdBack期间出现问题 - 问题ArgumentNullException:MvxWeakEventSubscription中缺少源事件信息 参数名称:sourceEventInfo 在Cirrious.CrossCore.WeakSubscription.MvxWeakEventSubscription2[System.Windows.Input.ICommand,System.EventArgs]..ctor (ICommand source, System.Reflection.EventInfo sourceEventInfo, System.EventHandler
1 targetEventHandler)[0x00028] /Volumes/WORKSPACE/Workspace/V3.5/framework/framework/MvvmCross-3/CrossCore/Cirrious.CrossCore/WeakSubscription/MvxWeakEventSubscription.cs :52 在/Volumes/WORKSPACE/Workspace/V3.5/framework/framework/MvvmCross-3/CrossCore中的Cirrious.CrossCore.WeakSubscription.MvxCanExecuteChangedEventSubscription..ctor(ICommand source,System.EventHandler1 eventHandler) [0x00000] in /Volumes/WORKSPACE/Workspace/V3.5/framework/framework/MvvmCross-3/CrossCore/Cirrious.CrossCore/WeakSubscription/MvxCanExecuteChangedEventSubscription.cs:21 at Cirrious.CrossCore.WeakSubscription.MvxWeakSubscriptionExtensionMethods.WeakSubscribe (ICommand source, System.EventHandler
1 eventHandler)[0x00003] /Cirrious.CrossCore/WeakSubscription/MvxWeakSubscriptionExtensionMethods.cs:68 在Cirrious.MvvmCross.Binding.Touch.Target.MvxUIControlTouchUpInsideTargetBinding.SetValueImpl(System.Object target,System.Object value)[0x00045] in /Volumes/WORKSPACE/Workspace/V3.5/framework/framework/MvvmCross-3/Cirrious/ Cirrious.MvvmCross.Binding.Touch /目标/ MvxUIControlTouchUpInsideTargetBinding.cs:74 在/Volumes/WORKSPACE/Workspace/V3.5/framework/framework/MvvmCross-3/Cirrious/Cirrious.MvvmCross.Binding中的Cirrious.MvvmCross.Bindings.Bindingget.Marx.MvxConvertingTargetBinding.SetValue(System.Object value)[0x000bd] /Bindings/Target/MvxConvertingTargetBinding.cs:64 在Cirrious.MvvmCross.Bindings.Bindings.MvxFullBinding.UpdateTargetFromSource(System.Object value)[0x00036] in /Volumes/WORKSPACE/Workspace/V3.5/framework/framework/MvvmCross-3/Cirrious/Cirrious.MvvmCross.Binding/Bindings /MvxFullBinding.cs:162
答案 0 :(得分:6)
您需要使用以下代码创建LinkerPleaseInclude.cs文件:
public class LinkerPleaseInclude
{
public void Include(ICommand command)
{
command.CanExecuteChanged += (s, e) => { if (command.CanExecute(null)) command.Execute(null); };
}
}
编辑(根据我的评论):