In MVC you can say:
Html.TextBoxFor(m => m.FirstName)
This means you're passing the model property as the parameter (not the value), so MVC can get metadata and so on.
I'm trying to do a similar thing in a C# WinForms project and can't work out how. Basically I have a set of bool properties in a User Control, and I'd like to enumerate them in a dictionary for easier access:
public bool ShowView { get; set; }
public bool ShowEdit { get; set; }
public bool ShowAdd { get; set; }
public bool ShowDelete { get; set; }
public bool ShowCancel { get; set; }
public bool ShowArchive { get; set; }
public bool ShowPrint { get; set; }
Somehow I'd like to define a Dictionary object with Enum Actions as the key, and the property as the value:
public Dictionary<Actions, ***Lambda magic***> ShowActionProperties = new Dictionary<Actions,***Lambda magic***> () {
{ Actions.View, () => this.ShowView }
{ Actions.Edit, () => this.ShowEdit }
{ Actions.Add, () => this.ShowAdd}
{ Actions.Delete, () => this.ShowDelete }
{ Actions.Archive, () => this.ShowArchive }
{ Actions.Cancel, () => this.ShowCancel }
{ Actions.Print, () => this.ShowPrint }
}
I need to be passing the property, not the property value, into the dictionary as they may change at runtime.
Ideas?
-Brendan