Bear
Bear

Reputation: 1107

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?

Upvotes: 1

Views: 178

Answers (1)

Dk358
Dk358

Reputation: 179

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.

Upvotes: 1

Related Questions