question

JassimAlRahma-9056 avatar image
0 Votes"
JassimAlRahma-9056 asked LeonLu-MSFT commented

Celsius and Fahrenheit symbols

Hi,

I have the following in my App.xaml:

 <?xml version="1.0" encoding="utf-8" ?>
 <Application xmlns="http://xamarin.com/schemas/2014/forms"
     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
     x:Class="MyApp.App">
     <Application.Resources>
         <ResourceDictionary>
             <x:String x:Key="SymbolCelsius">\x00B0</x:String>
         </ResourceDictionary>
     </Application.Resources>
 </Application>


How can I display it now on a Label control?

I tried the following but did not work:

 MyLabel,Text = App.Current.Resources["SymbolCelsius"];

Thanks,
Jassim



dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LeonLu-MSFT avatar image
0 Votes"
LeonLu-MSFT answered LeonLu-MSFT commented

Hello,​

Xamarin could use HTML Entities to display SymbolCelsius, you can try to use following string in your <ResourceDictionary>.

<x:String x:Key="SymbolCelsius">&#186;</x:String>


And use it like following code.

mylabel.Text = App.Current.Resources["SymbolCelsius"].ToString();


Best Regards,

Leon Lu



If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@JassimAlRahma-9056 May I know if you have got any chance to check my answer? I am glad to help if you have any other questions

0 Votes 0 ·

This is what worked for me:

 <Application.Resources>
     <ResourceDictionary>
         <x:String x:Key="SymbolCelsius">\x00B0</x:String>
     </ResourceDictionary>
 </Application.Resources>


Thank you

0 Votes 0 ·
LeonLu-MSFT avatar image LeonLu-MSFT JassimAlRahma-9056 ·

Thanks for your sharing.

0 Votes 0 ·