How to set Unicode character as Content of Label in the code-behind? How to set Unicode character as Content of Label in the code-behind? wpf wpf

How to set Unicode character as Content of Label in the code-behind?


Use a unicode escape sequence, rather than a character entity:

FalsePositiveInput.Content = "\u2713";


+1 for 一二三

Just one remark: If you want to use extended Unicode, you need to use not \u, but \U and 8 characters, e.g. to display left-pointing magnifying glass (1F50D http://www.fileformat.info/info/unicode/char/1f50d/index.htm) you need to use:

this.MyLabel.Text = "\U0001F50D";

Alternatively as was suggested you can paste right into your source code and then you don't need comments like "//it is a magnifying glass", but then you will have to save your source code in Unicode, which is probably not what you want.


Return Check symbolThis works in the code-behind and report :)

public static string FormatValue(object value, string format)    {        if (value == null) return "";                   Type type = value.GetType();        if (type == typeof(bool))        {            if (string.IsNullOrEmpty(format))            {                if ((bool)value)                {                    return "Yes";                }                else                {                    return "No";                }            }            else            {                                    if ((bool)value)                {                    return ((char)0x221A).ToString();                 }                else                {                    return "";                }            }        }        return value.ToString();    }