I've been searching for this a lot, but I haven't found anything close to what I need, and maybe it's something simple, but the things that I get are only how to concatenate strings using "+" or the Format procedure.
What I would like to know is how to call a string that contains the HEX format of a color by changing another string.
Heres and example:
I have named the following strings:
string Color_Option1 = "#FF17868B";
string Color_Option2 = "#FFFFFFFF";
string Color_Option3 = "#FF000000";
And this variable:
private static string m_optionclicked = "";
public static string OptionClicked
{
get { return m_optionclicked; }
set { m_optionclicked = value; }
}
Then I have 3 buttons and one TextBlock, and when a button is clicked they put a value on "OptionClicked", ex:
OptionClicked = "Option2";
So depending on which button is clicked I want to change the background color of the TextBlock like this:
TextBlock.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("Color_" + OptionClicked));
But I get and error everytime on the background line, does anyone knows how can I call the string called "Color_Option2" with a similar syntaxis?
I've made sure that OptionClicked has the value "Option2" and it actually works if I write "Color_Option2" instead of concatenating the string and variable.
BTW, this is a simplified example, I have a lot of buttons, textblocks, and colors, so making a chain of "If"s or determining one by one would make my life miserable.
Thanks in advance.