Hey guys,
I have an app where you can scan barcodes.
If a view is loading, I set the focus programmatically on the searchbar ( MySearchBar.Focus() ).
With the following code I prevent the keyboard to popup:
class HideSearchBarKeyboard : SearchBarRenderer {
public HideSearchBarKeyboard(Context context) : base(context) {
}
protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> e) {
base.OnElementChanged(e);
if (e.OldElement == null) {
var field = this.GetType().GetField("HandleKeyboardOnFocus", BindingFlags.Instance | BindingFlags.NonPublic);
field.SetValue(this, false);
}
}
}
Today I upgraded Xamarin.Forms to version 3.6 and after that the "field" property is always null.
I checked the github page and found some requests like the pull request "4248" (can't post links, sorry)
But I have absolutely no clue, how I can now hide the keyboard when I focus the searchbar.
So the previews behavior was:
- Open some view = keyboard hidden
- MySearchBar.Focus() = keyboard hidden
- User clicked on searchbar = keyboard shown
Can someone guide me to the right direction?