Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!

My problem is that I am coding a UserControl. Is basically a textbox that when it get focus it opens a popup. The popup contains buttons, a grid and others. The popup also has its StaysOpen property to False and the IsOpen is set to true on the textbox previewmousedown event.

The thing is that once I click the textbox it opens but when I click outside the popup it does not close.

A strange behavios is that when I click a button inside the popup and then outside of it, it works normally. It closes.

What am I doing wrong?
Posted

The popup probably doesn't get focus when it is shown. The close action is performed when it looses its focus, but you cannot lose focus if you didn't get it in the first place.
As a solution you might want to set the focus on the popup. When you click the button on the popup you also give it focus but manually.

Good luck!
 
Share this answer
 
Comments
Luis D. Aguilar 30-Sep-11 12:51pm    
I can't set focus on a popup. Setting focus on any element inside the popup does not work.
E.F. Nijboer 30-Sep-11 14:14pm    
It inherits Focusable from UIElement and I think that should be true.
http://msdn.microsoft.com/en-us/library/system.windows.uielement.focusable.aspx

Also, check out this link:
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/3e7cc288-f146-4b9d-9157-41efb1623c71/
set this
<Popup StaysOpen="False" />
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900