ColorHelper.

ColorFromString(string, Dictionary<Color?, string>) Method

Summary

This function tries to convert a given string into a Color in the following order: 1. If the string starts with '#' the function tries to get the color from the hex-code 2. else the function tries to find the color in the color names Dictionary 3. If 1. + 2. were not successful the function adds a '#' sign and tries 1. + 2. again
Namespace
MahApps.Metro.Controls
Containing Type
ColorHelper

Syntax

public static Color? ColorFromString(string colorName, Dictionary<Color?, string> colorNamesDictionary)

Parameters

Name Type Description
colorName string The localized name of the color, the hex-code of the color or the internal color name
colorNamesDictionary Dictionary<Color?, string> Optional: The dictionary where the ColorName should be looked up

Return Value

Type Description
Color? the Color if successful, else null