How to decode spacial character in xamairn forms
Inside my label text = "Sample & Text"
instead of showing original text, its showing "Sample & Text"
so how to solve this?
&
is used for displaying &
in XAML. If you want to display Sample & Text on code behind, there's no need to encode it to Sample & Text
. You could set the value directly. i.e. here is a list view's items source:
var list = new List<string>();
for (int i=0; i<10; i++)
{
var str = "Sample & Text";
list.Add(str);
}
listView.ItemsSource = list;
It shows correctly:
However, if your original text from the server is Sample & Text
and you want to display the decoded format, you can try System.Net.WebUtility.HtmlDecode()
:
var str = System.Net.WebUtility.HtmlDecode("Sample & Text");