title: Xamarin Forms custom Entry renderer that hides soft keyboard
body: <p>In a Xamarin Forms app, I am trying to create a custom <code>Entry</code> implementation that does not automatically display the soft keyboard when it is focused. The goal is to use one instance of this entry alongside other conventional entries on a page.</p>
  
  <p>I am familiar with the recommended Xamarin Forms pattern for custom view rendering, and have successfully created both the Entry and its renderer, as follows:</p>
  
  <pre><code>public class BlindEntry : Entry
  {
  }
  
  [assembly: ExportRenderer(typeof(BlindEntry), typeof(BlindEntryRenderer))]
  
  public class BlindEntryRenderer : EntryRenderer
  {
      protected override void OnElementChanged(ElementChangedEventArgs&lt;Entry&gt; e)
      {
          base.OnElementChanged(e);
  
          if (Control != null)
          {
              Control.FocusChange += Control_FocusChange;
          }
      }
  
      private void Control_FocusChange(object sender, FocusChangeEventArgs e)
      {
          if (e.HasFocus)
          {
              // What goes here?
          }
          else
          {
              // What goes here?
          }
      }
  }
  </code></pre>
  
  <p>To show and hide the soft keyboard, I imagine one of the recommendations from <a href="https://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard">this question</a> will provide the solution, but there are many different opinions on which is the best approach. Also, even after choosing a suitable pattern, I am not clear how to access the required native Android APIs from within the above custom renderer.</p>
  
  <p>For example, I know that I can obtain a reference to an <code>InputMethodManager</code> using the following call (from within an <code>Activity</code>), but it is not obvious how to reference the containing activity from inside the renderer:</p>
  
  <pre><code>var imm = GetSystemService(InputMethodService)
  </code></pre>
  
  <p>Thanks, in advance, for your suggestions.</p>
  
  <p>Tim</p>