Add degree symbol to label

I want to add a degree symbol to this label in xaml. Please tell me how to do this?

<Label Content="{Binding CelsiusTemperature}"  />
+4
source share
2 answers

You can use ContentStringFormatfor Label:

Gets or sets a compound string that indicates how to format the property Contentif it is displayed as a string.

Example:

<Label Content="{Binding Path=CelsiusTemperature}" 
       ContentStringFormat="{}{0}Β°" />
+2
source

Use TextBlockinstead Labeland set the StringFormatbinding property :

<TextBlock Text="{Binding CelsiusTemperature, StringFormat={}{0}Β°}"/>

- , ContentStringFormat Binding StringFormat TextBlock Content:

<Label>
    <TextBlock Text="{Binding CelsiusTemperature, StringFormat={}{0}Β°}"/>
</Label>
+3

Source: https://habr.com/ru/post/1537854/


All Articles