Z
Z
Zulkund2017-02-09 13:36:11
WPF
Zulkund, 2017-02-09 13:36:11

How to check multiple elements for an empty string in WPF?

Good afternoon! In my WPF project, there are several TextBlocks included in a StackPanel (Name = MainPanel), how can I loop through all of them for an empty string?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sanostee, 2017-02-09
@andrewpianykh

bool isEmpty = MainPanel.Children
    .OfType<TextBlock>()
    .Any(s => string.IsNullOrWhiteSpace(s.Text));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question