0

I am working on a windows phone 8 app and need to add a currency hex code to a textblock text property programmatically. It works perfectly on xaml:

<TextBlock  Text="&#x20a6;" />

but when i use the statement below:

textblock.text = "&#x20a6;"; 

it just display the text as it is. How can I do this programmatically?

Sunday Okpokor
  • 721
  • 6
  • 18

2 Answers2

1

You need the Unicode value in the string. Using Unicode character escape sequences in strings.

  textblock2.Text = "\u20a6";

Or you can use the hex number and convert to a char.

  textblock2.Text = char.ConvertFromUtf32(0x20a6);

Also, you can simply use the character:

textblock2.Text = "₦";
Walt Ritscher
  • 6,977
  • 1
  • 28
  • 35
0

Try this:

            var formatter = new System.Globalization.CultureInfo("HA-LATN-NG");
            formatter.NumberFormat.CurrencySymbol = "₦";


            textblock.text  = long.Parse("20a6", NumberStyles.AllowHexSpecifier 
            | NumberStyles.HexNumber,
            formatter).ToString("c");

But, if you need a decimal value, see this link.

Community
  • 1
  • 1
MikeG
  • 523
  • 4
  • 13
  • this will retrieve the user's current region or currency format. I just need to work with a set of provided currency codes I have. the currency code 20a6 is for Nigeria naira – Sunday Okpokor Dec 29 '14 at 22:37