简体   繁体   English

wpf中的LostFocus事件问题和按钮命令

[英]LostFocus event problem and Button Command in wpf

I have a textbox and inside its lost focus event, I show a new window and give the user choices, I also have a button below the text box. 我有一个文本框,在其失去焦点的事件内,我显示一个新窗口并给用户选择,文本框下方也有一个按钮。

Now, when I change the value of the text box..and click the button (while the cursor is still inside the text box...) the lost focus event gets fired... but as I show a modal window dialog, the button's click event is not being fired.... 现在,当我更改文本框的值..并单击按钮(当光标仍在文本框内时...),丢失焦点事件被触发...但是当我显示模式窗口对话框时,按钮的点击事件未触发。

Is there a way to get around it? 有办法解决吗?

Don't affect significant ui via the lost focus event. 不要通过丢失焦点事件来影响重要的用户界面。 You're popping up a new window in the wrong situation- if your user ever wants to do anything interesting after entering a value in that textbox, the modal dialog will pop up because the textbox will lose focus. 您在错误的情况下弹出一个新窗口-如果您的用户在该文本框中输入值后想要做任何有趣的事情,则会弹出模式对话框,因为该文本框将失去焦点。 Instead, consider making an editable combobox where the items in the drop down are your user choices. 相反,请考虑制作一个可编辑的组合框,其中下拉菜单中的项是您的用户选择。

If you want to hack, you may be able to get away with only popping up suggestions if the textbox has no text in it on a lost focus event. 如果您想入侵,则在焦点丢失事件中文本框中没有文本的情况下,仅弹出建议就可以逃脱。 I think it's a lousy solution, but it might fit your constraints. 我认为这是一个糟糕的解决方案,但它可能适合您的约束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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