Display HTML snippets in WPF form

I would like to show HTML snippets in my form. I looked through several examples on the Internet regarding the use of a web form or document layout, etc., and nothing works for me.

We have a system on our website where a user can enter a notification using the Real Text Editor (CKEditor). The message is saved in the database, and the WPF application on all computers in the office should display the message.

I want to support HTML in my WPF program. HTML is not on the page, it is part of the HTML in db that should be rendered in a visualized form in a WPF application.

For example, if someone logs into <img src="http://www.google.com/google.jpg" /> , he will show the image in the wpf application when I extract it from the database and show it in the form.

What is the best way to do this?

PS I can’t use a web browser because Windows "AllowTranparency" is set to true.

+6
source share
1 answer

Add a WebBrowser control to the application:

 <Window x:Class="WpfBrowser.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <WebBrowser Height="311" HorizontalAlignment="Left" Name="webBrowser1" VerticalAlignment="Top" Width="503" /> </Grid> </Window> 

And then use NavigateToString for WebBrowser to load the page from the html line:

 webBrowser1.NavigateToString("<html><head></head><body>First row<br>Second row</body></html>"); 
+6
source

Source: https://habr.com/ru/post/909531/


All Articles