Setting the Focus to an Entry in Xamarin.Forms

后端 未结 6 873
天命终不由人
天命终不由人 2020-12-20 13:58

This is just a simplified example, but I\'m trying to set this up so that when I open up this page in my Application, the first thing that happens is the keyboard pops up re

6条回答
  •  不思量自难忘°
    2020-12-20 14:16

    So long as the element to focus on is the topmost element, this should work. I place this in the OnAppearing method.

    base.OnAppearing();
    Entry entry = this.FindByName("NameOfEntryElement");
    entry.Focus();
    

    The source of this info is here: https://forums.xamarin.com/discussion/100354/entry-focus-not-working-for-android

    There is further discussion in the article about timing issues.

提交回复
热议问题