简体   繁体   中英

Multiple textbox validation in WPF

I would like to check if exists any empty textBox on my Window. I found pretty nice solution for windowForms

if(this.Controls.OfType<TextBox>().Any(t => string.IsNullOrEmpty(t.Text)) {
...
}

by @StriplingWarrior

What is equivalent of this.Control in WPF? How to solve it in smart way?

try this

LogicalTreeHelper.GetChildren(p_Parent).OfType<TextBox>().ToList().Where(d => string.IsNullOrWhiteSpace(d.Text)).ToList();

I have used it various places. Hope it helps.

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