尝试通过发送字符串值时出现以下异常MessagingCenter
。例外是在PopupPage上。
异常详情:
异常:>>System.Reflection.TargetInvocationException:调用的目标已抛出异常。---> System.NullReferenceException:对象引用未设置为对象的实例。在CatholicBrain.Views.BibleOrderGamePage.<.ctor>b__3_0 (CatholicBrain.Model.BibleOrderGameViewModel s, System.String answer) [0x00001] 在 F:\My Projects\Xamarin\catholicbrain-mobile-app\CatholicBrain\CatholicBrain\Views\BibleOrderGamePage .xaml.cs:30 at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) 在 System.Reflection.RuntimeMethodInfo.Invoke (System.对象 obj,System.Reflection.BindingFlags invokeAttr,System.Reflection.Binder binder,System.Object[] 参数,System.Globalization。
消息中心.发送
MessagingCenter.Send<BibleOrderGameViewModel, string>(this, "rightanswer", selectedItem.Answer);
await PopupNavigation.Instance.PopAsync();
消息中心.订阅
MessagingCenter.Subscribe<BibleOrderGameViewModel, string>(this, "rightanswer", (s, answer) =>
{
answerLabel.Text = answer;
});