title: Xamarin Forms Entry Keyboard Stop From Losing Focus
body: <p>I have an Entry and a Button:</p>
  
  <pre><code>&lt;StackLayout&gt;
      &lt;CustomViews:ChatEntryView x:Name="ChatEntry" /&gt;
      &lt;Button Text="Send" Command="SendCommand"/&gt;
  &lt;/StackLayout&gt;
  </code></pre>
  
  <p>What I wanted to achieve here is that when the user starts types something on the Entry control and then presses the button, it should not hide the keyboard (or lose the Entry Focus).</p>
  
  <p>The ChatEntryView here is just actually a custom view that inherits from the Entry control and what I did inside:</p>
  
  <p>1.) Added an Unfocused handler</p>
  
  <pre><code>Unfocused += ChatEntryView_Unfocused;
  
  void ChatEntryView_Unfocused(object sender, FocusEventArgs e)
  {
      this.Focus();
  }
  </code></pre>
  
  <p>2.) Tried Handling on PropertyChanged</p>
  
  <pre><code>protected override void OnPropertyChanged(string propertyName = null)
  {
      this.Focus();
      base.OnPropertyChanged(propertyName);
  }
  </code></pre>
  
  <p>3.) Tried Handling on PropertyChanging</p>
  
  <pre><code>protected override void OnPropertyChanging(string propertyName = null)
  {
      this.Focus();
      base.OnPropertyChanging(propertyName);
  }
  </code></pre>
  
  <p>But all the three methods doesn't seem to work. I was able to do a work around on IOS by making a custom renderer and it's not very neat (by actually interfacing to the Control.ShouldEndEditing on IOS).</p>
  
  <p>But my problem now is on Android, as I don't exactly know how to do this on Android and there's no Control.ShouldEndEditing (the interface on Android) that I can work with.</p>
  
  <p>What happens by using the handlers above is that, the keyboard for the entry view still loses focus and then immediately gets focuses again which is very odd.</p>
  
  <p>The keyboard pushes down (loses focus) and then pushes up (forced focus).</p>