简体   繁体   中英

Textbox doesn't lose focus when clicking outside of it when inside Popup?

I am working on a Windows 8.1 Store App using Windows Runtime.

I have a UserControl which holds a StackPanel which holds a number of TextBoxes.

When I place the UserControl on a Page and When I place the user control in a Popup I get different focus behaviour for the TextBox controls.

UserControl on Page: When I click on a TextBox it is focused, when I click outside the TextBox on it's parent (StackPanel) the TextBox loses focus.

UserControl in Popup: When I click on a TextBox it is focused, when I click outside the TextBox on it's parent (StackPanel) the TextBox does not lose focus.

What I want is for it to behave the same in the Popup as it does when on the Page.

What is causing this behaviour when the UserControl is in a Popup and how can I get it to behave the same as it does on the page when in the Popup?

It likely has something to do with the z-index of the popup. I think you should try to detect when the mouse is clicked outside of the popup and change focus at that time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM