What the best way (preferably cross-platform) to dismiss keyboard when user starts scrolling sfListView in Xamarin project for IOS and Android? If no cross-platform solution exists - would be glad to hear solutions for both IOS and Android separately. Thank you in advance
Asked
Active
Viewed 335 times
0
-
Did your solve your problem or tried my solution? – nevermore May 15 '19 at 05:53
-
Yes, your solution worked. Marked it as answer – JohnDiGriz May 31 '19 at 10:52
1 Answers
0
When looking into documention of sfListView, you can find the Identifying scroll state changes
part, so you can dismiss keyboard in this event:
listView.ScrollStateChanged += ListView_ScrollStateChanged;
private void ListView_ScrollStateChanged(object sender, ScrollStateChangedEventArgs e)
{
if (e.ScrollState != ScrollState.Idle)
{
//dismiss keyboard
DependencyService.Get<IKeyboardHelper>().HideKeyboard();
}
}
To dismiss the keyboard, you have to use DependencyService:
You can use the code in this thread.
Note: Remember to add this line before the start of the namespace in each of your KeyboardHelper classes or the DependencyService will not find them.
[assembly: Xamarin.Forms.Dependency(typeof(xxxxxxKeyboardHelper))]

nevermore
- 15,432
- 1
- 12
- 30