WPF 判断control的Text不能为空foreach var t in PanelChildren if t is Control control
可以使用以下代码判断control的Text是否为空:
if (control is TextBox textBox && string.IsNullOrEmpty(textBox.Text)) { // Text为空 } else if (control is ComboBox comboBox && comboBox.SelectedItem == null) { // 选中项为空 }
原文地址: https://www.cveoy.top/t/topic/cEkJ 著作权归作者所有。请勿转载和采集!