C# 泛型字典验证控件输入 - 使用 Dictionary<Type, Func<FrameworkElement, bool>>
Dictionary<Type, Func<FrameworkElement, bool>> validationMethods = new Dictionary<Type, Func<FrameworkElement, bool>>() { { typeof(TextBox), (element) => !string.IsNullOrEmpty(((TextBox)element).Text) }, { typeof(ComboBox), (element) => !string.IsNullOrEmpty(((ComboBox)element).Text) }, { typeof(DatePicker), (element) => !string.IsNullOrEmpty(((DatePicker)element).Text) } };
foreach (var element in Panel.Children.OfType
原文地址: https://www.cveoy.top/t/topic/j5EH 著作权归作者所有。请勿转载和采集!