locked
InputPane not closing when Popup dismissed RRS feed

  • Question

  • I have a modal popup that is not in a visual tree of a page with a custom handling of InputPane's Showing and Hiding events to implement moving a focused control in view. This works perfectly. My old solution had a popup in a visual tree and I let the standard code to handle this. It never worked properly, that's why this new solution. But now I have a problem that when soft keyboard is open when I dismiss the popup, it stays open. The popup uses IsLightDismissEnabled = false and it is resized to fill the screen to prevent user tapping on something else. I dismiss a popup by tapping on a button which in turn fires a command in view model which sets popup's IsOpen to false via binding to its own property. Any ideas how to make the keyboard close? I am looking at simulating tap events, but it seems I cannot set the event's parameters. Thanks.

    Monday, September 9, 2013 9:44 AM

Answers

  • So it's definitely that ListViewItem that prevents InputPane from closing. I tried it in a test project and got the same problem. And then in Closed event of the popup I set focus to some button on the page and the keyboard closes. I'll try it tomorrow in my app and if it works which I expect it to, I am setting this as an answer.
    • Marked as answer by IvanIL Tuesday, September 10, 2013 7:00 AM
    Monday, September 9, 2013 6:41 PM

All replies

  • You can't programmatically control the keyboard.  My question is:  why is it open?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, September 9, 2013 1:06 PM
    Moderator
  • I know I cannot hide it directly. The scenario is following: Keyboard is closed. I tap on a button in AppBar, close AppBar, set IsOpen of a popup to true vie binding from viewmodel, popup opens. I tap into a textbox, keyboard goes up and moves the textbox correctly into a view. I use popup's RenderTransform for this. Now I tap on button on a popup. IsOpen is set again via binding in view model. Popup closes, keyboard stays open. I had to add ScrollViewer with IsTabStop = true as a child of the popup and user control as a content of the scrollviewer to be able to dismiss the keyboard when tapping on a control without keyboard input. I found the solution here and it works.
    Monday, September 9, 2013 1:22 PM
  • Last thing I found out today is that when the popup goes, focus is set to a listviewitem of one of listviews on the underlying page. I think this is the problem as ListViewItem probably does not change a state of InputPane. I tap on a button to close the popup, but somehow this is ignored. Perhaps it's too quick to register.
    Monday, September 9, 2013 2:46 PM
  • So it's definitely that ListViewItem that prevents InputPane from closing. I tried it in a test project and got the same problem. And then in Closed event of the popup I set focus to some button on the page and the keyboard closes. I'll try it tomorrow in my app and if it works which I expect it to, I am setting this as an answer.
    • Marked as answer by IvanIL Tuesday, September 10, 2013 7:00 AM
    Monday, September 9, 2013 6:41 PM