自定义属性
代码语言:javascript复制class TreeListColumnAttribute: Attribute
{
public string mColumnHeader;
public TreeListColumnAttribute(string Name)
{
mColumnHeader = Name;
}
}
获取属性
代码语言:javascript复制projectListView.ColumnsSource = typeof(ProjectListNodeItem).GetProperties().Select(o => new TreeListColumn()
{
Width=90,
FieldName = o.Name,
Header = o.GetCustomAttribute<TreeListColumnAttribute>().mColumnHeader
});
通过自定属性,定义listview的标题