控制弹出窗口打开和关闭焦点
我有一个弹出窗口,其中包含多个元素、一个列表视图、一个文本框和一个按钮。这些运行良好,如果您使用按钮关闭弹出窗口,它也可以工作,但是当我尝试在失去焦点时关闭弹出窗口时,当我单击列表视图中的元素时,它会关闭。有什么办法解决这个问题吗? FocusManager 属性是正确的选择吗?
I have a popup which contains multiple elements, a list view, a text box and a button. These are operating fine, and if you use the button to close the popup it works as well, but when i tried to make the popup close when it lost focus, it closed when i clicked an element in the listview. Is there any way around this? Is the FocusManager property the way to go?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Popup 元素上设置 FocusManager.IsFocusScope = True ,这样只要他的子元素之一拥有焦点,它就会保持焦点。
Set FocusManager.IsFocusScope = True on your Popup element, so it keep focus as long as one of his children has it.
请尝试代码中弹出控件的stayopen属性。如果它不起作用,请发布您的代码。
Please try the stayopen property of the popup control in you code. If it is not working please post your code.
您应该像这样在弹出窗口上设置 StaysOpen 属性:
http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.popup.staysopen.aspx
You should just set the StaysOpen property on your popup like this:
http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.popup.staysopen.aspx