How can i display html text in list control
-
23 กันยายน 2554 8:31
Hi ,
I am new to WP7. I want to display HTML string(text wtih html tags) in the list control. Lets say I am having 3 strings as below.
1) Head <b>northeast</b>
Head northeast // desired output
2) Slight <b>left</b>
Slight left // desired output
3) Continue onto <b>NH 8</b><div style="font-size:0.9em">Go through 2 roundabouts</div><div style="font-size:0.9em">Pass by Petrol Pump (on the left in 31.1 km)</div>
Continue onto NH 8
Go through 2 roundaboutsPass by Petrol Pump (on the left in 31.1 km)I want to show them in list control,textblock in such a way that it identifyies the html tags and displays text accordingly so it removes the html tagsand so on.. Meaning display text in textblock that is aware of html tags.
My Try:
1) Webcontrol
On button click i try below code but its not even showing me the Webbrowser control.....
string arrHTML = "Head <b>northeast</b>"; // fill html strings webBrowser.IsScriptEnabled = true;
webBrowser.NavigateToString(arrHTML); // show it
but the webcotrol it self is not getting displayed.
Query
1) any idea why webbrowser not getting displayed?
2) any alternate way to show html text in textbox/textblock in list control which understands html tags?
Your help will be great.
Thanks,
ตอบทั้งหมด
-
27 กันยายน 2554 9:56
Hi
I am not sure whether you can display html in listbox. Instead you can use WebBrowser control .
Ex:-
string sHTML = @"<html> Head <b>northeast</b> Slight <b>left</b> Continue onto <b>NH 8</b><div style=""font-size:0.9em"">Go through 2 roundabouts</div><div style=""font-size:0.9em"">Pass by Petrol Pump (on the left in 31.1 km)</div> </html>"; webBrowser1.DocumentText = sHTML;Regards
Dominic
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful -
27 กันยายน 2554 16:38
Thanks for your reply.
I did try with WebBrowser control, but as i said in my query, webBrowser itself is not getting displayed.
also i am getting error on webBrowser1.DocumentText // Method not found
I am using below code on button click for the webBrowser contrl. Any idea why webbrowser not getting displayed?private
void button1_Click(object sender, RoutedEventArgs
e)
{
webBrowser.IsEnabled =
true
;
webBrowser.Visibility = System.Windows.
Visibility
.Visible;
webBrowser.IsScriptEnabled =
true
;
webBrowser.NavigateToString("Head <b>northeast</b>");
}
- แก้ไขโดย PrasadDash 27 กันยายน 2554 16:40
-
29 กันยายน 2554 12:21
Hi
Are you talking about Windows Phone 7 ? If so post this in the following forum. You may get better responses.
http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/threads
Regards
Dominic
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful