Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Focus on listview

I'm having this weird problem that seems that the ListView is not focusable.
I have a page with an entry and a listview, when I tap on entry the keyboard is open but if I tap on the list the keyboard is still open and I can see that the Entry never really looses the focus.

So, what are my options here? It is an iOS project so customrenderers are an option but I really don't understand why it is not (at least) firing the endediting of the entry

Best Answer


  • VancleiMatheusVancleiMatheus USMember ✭✭

    Not sure why my comment was removed, so I'm posting it again

    So, what I did to circumvent this problem was:

    On my Xamarin page when an item on the list is tapped I call the listview focus method:


    Then I created a ListViewRenderer and made the list react to focus changes request:

    e.NewElement.FocusChangeRequested += NewElementOnFocusChangeRequested;

    _Finally, when the list receives the focus change request I force the endediting for the main view of the application:


    Not sure it is the best solution but it is working for me now, if anyone else have a better solution you are welcome to post, either way I hope this can helps anyone else with the same problem in the future.

  • LandLuLandLu Member, Xamarin Team Xamurai

    Try to set a property of UITableView in the custom renderer of ListView like:

    [assembly: ExportRenderer(typeof(ListView), typeof(CustomListViewRenderer))]
    namespace Sample.iOS
        public class CustomListViewRenderer : ListViewRenderer
            protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
                if (e.NewElement != null)
                    Control.KeyboardDismissMode = UIScrollViewKeyboardDismissMode.OnDrag;

    When the listview scrolls the keyboard will be dismissed in this way.

  • VancleiMatheusVancleiMatheus USMember ✭✭

    Unfortunately the KeyboardDismissMode works only if the users drags the view, it doesn't work on tap alone

  • VancleiMatheusVancleiMatheus USMember ✭✭

    Cool, that's more ellegant and it works, thank you.

Sign In or Register to comment.