c# - Dismiss soft keyboard -


i have page idea use external keyboards. when page loads, set focus on entry control , want hide soft keyboard.

this class want that:

internal class redactcontent : contentpage {     stacklayout stack = new stacklayout();     entry entry;      internal redactcontent()     {          entry = new entry();         content = new stacklayout         {             children = {                                 entry,                 //more code             }         };     }      protected override void onappearing()     {         base.onappearing();         entry.focus();         // hide keyboard     } } 

how can that?

possible create customentry closekeyboard method. need write custom renderers each platform. see http://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/

on android customentry class this:

[assembly: exportrenderer(typeof(customentry), typeof(customentryrenderer))] public class customentryrenderer :  entryrenderer {     public customentryrenderer()     {         hidekeyboard();     }      void hidekeyboard()     {         this.control.inputtype = 0;         inputmethodmanager inputmethodmanager = this.control.context.getsystemservice(context.inputmethodservice) inputmethodmanager;         inputmethodmanager.hidesoftinputfromwindow(this.control.windowtoken, hidesoftinputflags.implicitonly);     }      // ... } 

Comments