简体   繁体   中英

WPF prevent lost focus on TextBox

Is there a way to fully prevent lostFocus from a TextBox?

I would like to prevent any action from app(button clicks, switching focus to other TextBoxes) until I meet some conditions

I have figured out how to prevent switching focus from a TextBox, but this does not help with button clicks/commands:

textBox.PreviewLostKeyboardFocus += (sender, args) =>
{
    if(textBox.Text != "test")
    args.Handled = true;
};

But right now: how to disallow clicking on Buttons? (perfectly - disallow everything until I meet specific conditions)

Disable all your button by default. Then in your event, enable button by your conditions.

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