Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Forms Entry invoke Completed event

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.

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();
};

And within the EntryExt (which extends the Entry directly)

public void InvokeCompleted()
{
    Completed?.Invoke(this, null);
}

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'

Is there a way to invoke the Completed event? I'd rather not have a separate event handler for this within my views.

like image 286
MegaMiley Avatar asked Jan 07 '17 10:01

MegaMiley


1 Answers

Fixed the issue by changing

entryExt.InvokeCompleted(); 

inside the EditorAction to

((IEntryController)Element).SendCompleted(); 

which sends out the completed event back to the Entry base class.

like image 115
MegaMiley Avatar answered Sep 22 '22 22:09

MegaMiley