I have a user control where I have bounded a string to the xaml path. This makes it possible for me to choose colors like "Black" "Blue" and also use hexa numbers as a string to choose the color.
But I am not able to use the same string in the C# code. Which is shown in the example below:
SolidColorBrush blackBrush = new SolidColorBrush();
SolidColorBrush mySolidColorBrush = new SolidColorBrush();
mySolidColorBrush.Color = shieldGearModelRec.Gear.Color;
So the last string shieldGearModelRec.Gear.Color
is what I use as a binding in XAML. And it can convert strings to color either in color names or hexa description. But how can I do this in the code behind, that is in c#?
My searches found stuff like Convert string to Color in C# but this was not possible in windows phone. Is there anyway to accomplish this?
An Idea
Do I need to create a converter that reads the string, looks for # to determine if it is hexa or a color name and then using a hexa converter to find rgb, and a switch for the names? This does not seem like the smartest solution