我目前正在 Xamarin Forms 中开发登录和注册页面,将键盘的完成按钮更改为下一个并继续最后一个按钮后,我不再在 Android 上收到 Completed 事件(在 iOS 上工作正常)。在自定义渲染器中,我可以捕获 Control.EditorAction 事件,该事件现在的行为与 Completed 事件相同,但我似乎无法在条目本身上调用 Completed 事件。
在 EntryRenderer 中
Control.EditorAction += (object sender, TextView.EditorActionEventArgsargs) =>
{
if (entryExt.ReturnKeyType != ReturnKeyTypes.Next)
entryExt.Unfocus();
// Call all the methods attached to base_entry event handler Completed
entryExt.InvokeCompleted();
};
在 EntryExt 中(直接扩展 Entry)
public void InvokeCompleted()
{
Completed?.Invoke(this, null);
}
但由于错误,无法调用 Completed 事件
Error CS0070: The event `Xamarin.Forms.Entry.Completed' can only appear on the left hand side of += or -= when used outside of the type `Xamarin.Forms.Entry'
有没有办法调用 Completed 事件?我宁愿在我的视图中没有一个单独的事件处理程序。
通过更改解决了该问题
entryExt.InvokeCompleted();
在 EditorAction 内
((IEntryController)Element).SendCompleted();
它将完成的事件发送回 Entry 基类。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)