using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace Szmedi.RvKits.InfoManager.EAMTools { /// /// EAMFacilityCodeWin.xaml 的交互逻辑 /// public partial class EAMFacilityCodeWin { public EAMFacilityCodeWin() { DataContext = new EAMFacilityCodeViewModel(); InitializeComponent(); } private void DataGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) { if (e.PropertyName == "IsChecked") e.Cancel = true; if (e.PropertyDescriptor is PropertyDescriptor descriptor) { var readOnly = descriptor.Attributes.OfType().FirstOrDefault(); if (readOnly == null) { e.Column.IsReadOnly = true; } else { e.Column.IsReadOnly = readOnly.IsReadOnly; } var generate = descriptor.Attributes.OfType().FirstOrDefault(); if (generate != null) { e.Cancel = true; } var excelColumnAttribute = descriptor.Attributes.OfType().FirstOrDefault(); if (excelColumnAttribute != null) { e.Column.Header = excelColumnAttribute.ColumnName; } else { e.Column.Header = descriptor.DisplayName; } } // if (e.PropertyName == "Name") e.Column.Header = "姓名";硬编码 // if (e.PropertyName == "Email") e.Cancel = true;不生成列 } } }