反射,屬性
PropertyInfo[] columnProps = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public);
foreach (PropertyInfo columnProp in columnProps)
{
object[] attributes = columnProp.GetCustomAttributes(typeof(DataGridColumnAttribute), false);
if (attributes != null && attributes.Length > 0)
{
DataGridColumnAttribute attr = attributes[0] as DataGridColumnAttribute;
string name = columnProp.Name;
string header = attr.Header;
}