0

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;

1 Answer 1

2

This should do it:

string style = "ErrorLabel";
Style styItem = LayoutRoot.Resources[style] as Style;
fld.Settings.CellValuePresenterStyle = styItem;
Sign up to request clarification or add additional context in comments.

1 Comment

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 !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.