gbackmania
gbackmania

Reputation: 900

Getting the value of string variable

How can the string literal - "ErrorLabel" be replaced with string variable style in the second line ? FYI ..The style names will be stored in a xml file.

 string style = "ErrorLabel";
 Style styItem = LayoutRoot.Resources["ErrorLabel"] as Style;
 fld.Settings.CellValuePresenterStyle = styItem;

Upvotes: 0

Views: 110

Answers (1)

Adam Lear
Adam Lear

Reputation: 38778

This should do it:

string style = "ErrorLabel";
Style styItem = LayoutRoot.Resources[style] as Style;
fld.Settings.CellValuePresenterStyle = styItem;

Upvotes: 2

Related Questions