Here is how I tackled this to transforms Enums into Select Lists. Enum.cshtml (an Editor Template, with a UI Hint to point to it):
@model Enum
@Html.DropDownListFor(model => model, Model.ToSelectList(), "Select")
Then the Extension method used in the view:
/// <summary>
/// Gets a select list from an enum.
/// </summary>
/// <param name="enumObject">The enum object.</param>
/// <returns></returns>
public static SelectList ToSelectList(this Enum enumObject)
{
List<KeyValuePair<string, string>> selectListItemList = null;
SelectList selectList = null;
try
{
// Cast the enum values to strings then linq them into a key value pair we can use for the select list.
selectListItemList = Enum.GetNames(enumObject.GetType()).Cast<string>().Select(item => { return new KeyValuePair<string, string>(item, item.PascalCaseToReadableString()); }).ToList();
// Remove default value of Enum. This is handled in the editor template with the optionLabel argument.
selectListItemList.Remove(new KeyValuePair<string, string>("None", "None"));
// Build the select list from it.
selectList = new SelectList(selectListItemList, "key", "value", enumObject);
}
catch (Exception exception)
{
Functions.LogError(exception);
}
return selectList;
}
To refactor this solution into Check Box Lists, you could simply pass back the Key Value Pairs from the function and loop through them in the editor template.
I hope this is of some help.