Reputation: 176
HtmlFormattedLabel is not converting html tags to normal text when binding the HTML text to a property in view model after initialized view using custom renderer in xamairn forms. Html tags only converting if the HTML code is there while initializing the view, But not after initialized. I'm binding the value to the property. But in android project element changed event not triggering. I have an API for get the data and binding to the property when comes.I wanted to html code should convert to normal text when bind the data to the property in view model. Any help would be appreciated. Thanks
Upvotes: 0
Views: 82
Reputation: 419
Make it with custom renderer:
For IOS,
var attr = new NSAttributedStringDocumentAttributes();
var nsError = new NSError();
attr.DocumentType = NSDocumentType.HTML;
var myHtmlData = NSData.FromString(label.Text, NSStringEncoding.Unicode);
this.Control.AttributedText = new NSAttributedString(myHtmlData, attr, ref nsError);
For Android :
Html.FromHtml(label.Text).ToString().Trim();
Upvotes: 1