2

I am using a Hit on server and getting the content in Streamer. I then use a string where I get the Html code of the website. I have to use this in a WPF application. Which control should I use where I can put a url which contains html code to display in my wpf and HOW??

        string urlcode;
        HttpWebRequest request = WebRequest.Create("http://google.com/") as HttpWebRequest;
        HttpWebResponse response = request.GetResponse() as HttpWebResponse;
        StreamReader streamr = new StreamReader(response.GetResponseStream());
        urlcode = streamr.ReadToEnd();

4 Answers 4

2

Embed the WebBrowser control on the preview tab and pass the HTML into it using the NavigateToString or NavigateToStream methods.

Sign up to request clarification or add additional context in comments.

1 Comment

No news here. Why do you answer exactly what others have answered before?
1

Use the WebBrowser control and its NavigateToStream method:

XAML:

<Grid>
    <WebBrowser Name="webBrower"/>
</Grid>

Code:

WebRequest request = WebRequest.Create("http://google.com");
webBrower.NavigateToStream(request.GetResponse().GetResponseStream());

This is a simplified example. You would at least have to close/dispose the response object when navigation has finished.

Comments

0

Use a NavigationWindow to contain the page. You can then call the Navigate(Uri) method to traverse from page to page.

MSDN entry

Comments

0

You can use web browser control ,pass string containg HTML control to its NavigateToString method

  webB.NavigateToString(@"<html>HTML code go here </html>");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.