Xamarin Forms Entry调用Completed事件 [英] Xamarin Forms Entry invoke Completed event
问题描述
我目前正在Xamarin Forms中的登录和注册页面上工作,将键盘的完成"按钮更改为下一步"并继续进行最后一个操作后,我不再在Android上收到Completed事件(在iOS上运行正常) .在自定义渲染器中,我可以捕获Control.EditorAction事件,该事件现在的行为与Completed事件相同,但是我似乎无法在条目本身上调用Completed事件.
I'm currently working on a login and registration page within Xamarin Forms and after changing the done button of the keyboard to next and go on the last one I am no longer receiving the Completed event on Android (working fine on iOS). In the custom renderer I can catch the Control.EditorAction event which now acts the same as the Completed event but I can't seem to invoke the Completed event on the entry itself.
在EntryRenderer中
Within the 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)
And within the EntryExt (which extends the Entry directly)
public void InvokeCompleted()
{
Completed?.Invoke(this, null);
}
但是由于错误,无法调用Completed事件
But the Completed event cannot be invoked due to the error
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事件?我宁愿在视图中没有单独的事件处理程序.
Is there a way to invoke the Completed event? I'd rather not have a separate event handler for this within my views.
推荐答案
通过更改
entryExt.InvokeCompleted();
在EditorAction内
inside the EditorAction to
((IEntryController)Element).SendCompleted();
会将完成的事件发送回Entry基类.
which sends out the completed event back to the Entry base class.
这篇关于Xamarin Forms Entry调用Completed事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!