c# - Xamarin Forms Entry 调用 Completed 事件

标签 c# android xamarin xamarin.forms

我目前正在 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/

相关文章:

c# - RequestPermissions 不显示对话框 xamarin c#

c# - RDLC报告: Apply Filter to Report

android - 启动 android 通知设置 Activity 导致泄漏的 Intent 接收器

xaml - 如何在 Xamarin 表单上使用 Microsoft XAML 边框

android - 如何在 Travis 中禁用 Android 模拟器动画?

java - Android HttpURLConnection 始终未经授权的 401 响应(Spring Boot REST API)

visual-studio - Xamarin "Waiting for runtime checks to complete"和 VS 模拟器

c# - xpath where 子句返回 0 个节点

c# - 你调用的对象是空的

c# - Nunit 插件没有出现在 nunit 的插件列表中