private bool CheckGrid(Grid grid) { foreach (var child in grid.Children.OfType()) { if (child is TextBox textBox && string.IsNullOrEmpty(textBox.Text) || child is TextBlock textBlock && string.IsNullOrEmpty(textBlock.Text) || child is ComboBox comboBox && comboBox.SelectedItem == null || child is Grid childGrid && !CheckGrid(childGrid)) { return false; } } return true; }

优化下面的代码private bool CheckGridGrid grid foreach var child in gridChildrenOfTypeFrameworkElement if child is TextBox textBox && stringIsNullOrEmptytextBoxText return fal

原文地址: https://www.cveoy.top/t/topic/cEqY 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录