0

I want to build a sample application where you can preview HTML code.

For example:

<TabControl......>
    <tabItem Header="HTML".....>
        <!-
            Here I type my HTML code ...
            <html>
                <body>
                    <p>********Some Text*******</p>
                </body>
            </html>
            which would be saved in the database as it is.
        ->
    </TabItem>
    <tabItem Header="Preview".....>
        <!-
             On clicking this Tab the Preview of the
             above HTML code (read from the database)
             should be displayed.
        ->
    </TabItem>
</TabControl>

How do I display the preview?

3 Answers 3

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.

Comments

0

You can use the WebBrowser control but please do not use it - it is filled with memory leaks and does not dispose propoerly. I have spent lots of time looking for solutions to the problems it produces in production code to no avail.

A quick search on this site will show some of the "unsolved" issues becasue basically it is a wrapper for a COM object (hence unmanaged) version of Internet Explorer and while it seems to work beautifully for displaying an embedded page in WPF the problems far out weigh its appearance of simplicity.

What you can do is use the Microsoft HTML to XAML parser, add a flowdocument tag at the beginning and end of the string and push it into the FlowDocumentScrollViewer control.

Comments

0

You can Embed the WebBrowser Tools

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.