Reputation:
I have a Label that looks the following:
<Label Name="FalsePositiveInput" Content="✓">
This works but how can I do it in the code-behind? I tried this but obviously it's not working:
FalsePositiveInput.Content = "✓";
The character i want to display is a check mark symbol
Upvotes: 25
Views: 30865
Reputation: 982
+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.
Upvotes: 17
Reputation: 4544
just copy and past caractor from here
then your text in xamal looks like this
<Button Text="← Bla bla" >
Upvotes: 0
Reputation: 95
+1 for Dario,
If it's a check mark symbol you need just copy it from another source into your code.
Easily found on wikipedia for instance.
Here they are : ✓, ✔, ☑
Taken from : https://en.wikipedia.org/wiki/Check_mark
Upvotes: 0
Reputation: 21239
Use a unicode escape sequence, rather than a character entity:
FalsePositiveInput.Content = "\u2713";
Upvotes: 39
Reputation: 41
Return Check symbol This 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();
}
Upvotes: 4
Reputation: 5804
If the character is constant and know at compile time, I'm pretty sure you can simply write the character as-is in the source code file, without encoding it as HTML entity. In other words, source files can be Unicode-encoded and Visual Studio will take care of that (or at least it does for me).
Upvotes: 2