我目前正在 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 事件?我宁愿在我的 View 中没有单独的事件处理程序。
最佳答案
通过更改解决了问题
entryExt.InvokeCompleted();
在 EditorAction 中
((IEntryController)Element).SendCompleted();
它将完成的事件发送回 Entry 基类。
关于c# - Xamarin Forms Entry 调用 Completed 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41520308/