tags:

views:

54

answers:

1

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;
+2  A: 

This should do it:

string style = "ErrorLabel";
Style styItem = LayoutRoot.Resources[style] as Style;
fld.Settings.CellValuePresenterStyle = styItem;
Anna Lear
Thanks ! That works now, and I feel stupid ! For some reason earlier the compiler kept saying I cant use a variable even though the key for the ResourceDictionary is of type object !
GBackMania