SolidColorBrush aus hexadezimalem Farbwert erstellen
Ich möchte SolidColorBrush aus einem Hex-Wert wie #ffaacc erstellen. Wie kann ich das machen?
Auf MSDN habe ich:
<code>SolidColorBrush mySolidColorBrush = new SolidColorBrush(); mySolidColorBrush.Color = Color.FromArgb(255, 0, 0, 255); </code>
Also schrieb ich (unter Berücksichtigung meiner Methode erhält Farbe als#ffaacc
):
<code>Color.FromRgb( Convert.ToInt32(color.Substring(1, 2), 16), Convert.ToInt32(color.Substring(3, 2), 16), Convert.ToInt32(color.Substring(5, 2), 16)); </code>
Aber das gab als Fehler
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?