Ich möchte SolidColorBrush aus einem Hex-Wert wie #ffaacc erstellen. Wie kann ich das machen?
Auf MSDN habe ich:
SolidColorBrush mySolidColorBrush = new SolidColorBrush();
mySolidColorBrush.Color = Color.FromArgb(255, 0, 0, 255);
Also schrieb ich (wenn man bedenkt, dass meine Methode Farbe erhält als #ffaacc
):
Color.FromRgb(
Convert.ToInt32(color.Substring(1, 2), 16),
Convert.ToInt32(color.Substring(3, 2), 16),
Convert.ToInt32(color.Substring(5, 2), 16));
Aber das gab Fehler als
The best overloaded method match for 'System.Windows.Media.Color.FromRgb(byte, byte, byte)' has some invalid arguments
Auch 3 Fehler als: Cannot convert int to byte.
Aber wie funktioniert dann das MSDN-Beispiel?